Skip to content

Commit 72aeef2

Browse files
authored
[Interactive Graph] | (CX) | Use dynamically resizing textarea for Description field (#2771)
## Summary: The Interactive Graph "Description" field takes up a ton of vertical space by default. Instead of having fixed rows, I'm going to use the dynamically resizing textarea that was previously only used by radio. - Move AutoResizingTextArea to the shared editor components folder - Use it inside the interactive graph editor Issue: none | Before | After | | --- | --- | | <img width="351" height="414" alt="Screenshot 2025-08-06 at 2 57 46 PM" src="https://github.com/user-attachments/assets/dc14fe97-371f-4e39-af92-95f9de5c12fe" /> | <img width="350" height="263" alt="Screenshot 2025-08-06 at 2 57 52 PM" src="https://github.com/user-attachments/assets/11678dcb-518e-454b-b6ad-86c143d3eae9" /> | Demo https://github.com/user-attachments/assets/c3def134-9736-4c35-93c0-f4eb71086ce5 ## Test plan: Storybook - http://localhost:6006/?path=/story/editors-editorpage--demo - Add an interactive graph widget - Check that the Description field is only one line by default now when it's empty. - Type in it so it takes up multiple lines and confirm that it resizes dynamically Author: nishasy Reviewers: nishasy, mark-fitzgerald, ivyolamit, SonicScrewdriver, anakaren-rojas Required Reviewers: Approved By: mark-fitzgerald, ivyolamit Checks: ✅ 12 checks were successful, ⏹️ 5 checks were cancelled Pull Request URL: #2771
1 parent 32ba4b3 commit 72aeef2

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

.changeset/healthy-carpets-draw.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@khanacademy/perseus-editor": patch
3+
---
4+
5+
[Interactive Graph] | (CX) | Use dynamically resizing textarea for Description field

packages/perseus-editor/src/widgets/interactive-graph-editor/components/interactive-graph-description.tsx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import {View} from "@khanacademy/wonder-blocks-core";
2-
import {TextArea, TextField} from "@khanacademy/wonder-blocks-form";
2+
import {TextField} from "@khanacademy/wonder-blocks-form";
33
import {Strut} from "@khanacademy/wonder-blocks-layout";
44
import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
55
import {LabelLarge, LabelXSmall} from "@khanacademy/wonder-blocks-typography";
66
import {StyleSheet} from "aphrodite";
77
import * as React from "react";
88

9+
import {AutoResizingTextArea} from "../../../components/auto-resizing-text-area";
910
import Heading from "../../../components/heading";
1011

1112
import type {Props as EditorProps} from "../interactive-graph-editor";
@@ -21,6 +22,9 @@ export default function InteractiveGraphDescription(props: Props) {
2122

2223
const [isOpen, setIsOpen] = React.useState(true);
2324

25+
const uniqueId = React.useId();
26+
const descriptionTextAreaId = `${uniqueId}-description-textarea`;
27+
2428
return (
2529
<>
2630
<Heading
@@ -52,23 +56,21 @@ export default function InteractiveGraphDescription(props: Props) {
5256
/>
5357
</LabelLarge>
5458
<Strut size={spacing.small_12} />
55-
<LabelLarge tag="label">
59+
<LabelLarge tag="label" htmlFor={descriptionTextAreaId}>
5660
Description
57-
<TextArea
58-
rows={8}
59-
resizeType="vertical"
60-
value={ariaDescriptionValue}
61-
onChange={(newValue) =>
62-
onChange({
63-
fullGraphAriaDescription:
64-
// Save as undefined if the new value
65-
// is an empty string.
66-
newValue || undefined,
67-
})
68-
}
69-
style={styles.spaceAbove}
70-
/>
7161
</LabelLarge>
62+
<AutoResizingTextArea
63+
id={descriptionTextAreaId}
64+
value={ariaDescriptionValue}
65+
onChange={(newValue) =>
66+
onChange({
67+
fullGraphAriaDescription:
68+
// Save as undefined if the new value
69+
// is an empty string.
70+
newValue || undefined,
71+
})
72+
}
73+
/>
7274
</View>
7375
)}
7476
</>

packages/perseus-editor/src/widgets/radio/radio-option-settings.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {semanticColor, sizing} from "@khanacademy/wonder-blocks-tokens";
33
import {HeadingXSmall} from "@khanacademy/wonder-blocks-typography";
44
import * as React from "react";
55

6-
import {AutoResizingTextArea} from "./auto-resizing-text-area";
6+
import {AutoResizingTextArea} from "../../components/auto-resizing-text-area";
7+
78
import styles from "./radio-editor.module.css";
89
import {RadioOptionContentAndImageEditor} from "./radio-option-content-and-image-editor";
910
import {RadioOptionSettingsActions} from "./radio-option-settings-actions";

0 commit comments

Comments
 (0)