Skip to content

Commit 4dc475d

Browse files
(Textarea): add htmlReadOnly prop and a corresponding story, following Input
1 parent 78514d5 commit 4dc475d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/scripts/Textarea.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export type TextareaProps = {
2727
elementRef?: Ref<HTMLDivElement>;
2828
textareaRef?: Ref<HTMLTextAreaElement>;
2929
onValueChange?: (value: string, prevValue?: string) => void;
30+
readOnly?: boolean;
31+
htmlReadOnly?: boolean;
3032
} & TextareaHTMLAttributes<HTMLTextAreaElement>;
3133

3234
/**
@@ -48,6 +50,7 @@ export const Textarea = createFC<TextareaProps, { isFormElement: boolean }>(
4850
onChange: onChange_,
4951
onValueChange,
5052
readOnly,
53+
htmlReadOnly,
5154
...rprops
5255
} = props;
5356
const prevValueRef = useRef<string>();
@@ -68,6 +71,7 @@ export const Textarea = createFC<TextareaProps, { isFormElement: boolean }>(
6871
id={id}
6972
ref={textareaRef}
7073
className={taClassNames}
74+
readOnly={htmlReadOnly}
7175
{...rprops}
7276
onChange={onChange}
7377
aria-describedby={error ? errorId : undefined}

stories/Textarea.stories.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,26 @@ export const ReadOnly: ComponentStoryObj<typeof Textarea> = {
123123
},
124124
};
125125

126+
/**
127+
*
128+
*/
129+
export const ReadOnlyHtml: ComponentStoryObj<typeof Textarea> = {
130+
name: 'Read only (HTML)',
131+
args: {
132+
label: 'Input Label',
133+
value: 'Textarea Only',
134+
htmlReadOnly: true,
135+
},
136+
parameters: {
137+
docs: {
138+
description: {
139+
story:
140+
'Textarea control with readOnly status (passsed to HTML &lt;input&gt; element)',
141+
},
142+
},
143+
},
144+
};
145+
126146
/**
127147
*
128148
*/

0 commit comments

Comments
 (0)