Skip to content

Commit 571ab0f

Browse files
(Textarea): update markup for readOnly
1 parent b3d9288 commit 571ab0f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/scripts/Textarea.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import React, {
77
useRef,
88
} from 'react';
99
import classnames from 'classnames';
10+
import { Text } from './Text';
1011
import { FormElement, FormElementProps } from './FormElement';
1112
import { FieldSetColumnContext } from './FieldSet';
1213
import { useEventCallback } from './hooks';
@@ -45,6 +46,7 @@ export const Textarea = createFC<TextareaProps, { isFormElement: boolean }>(
4546
textareaRef,
4647
onChange: onChange_,
4748
onValueChange,
49+
readOnly,
4850
...rprops
4951
} = props;
5052
const prevValueRef = useRef<string>();
@@ -55,7 +57,11 @@ export const Textarea = createFC<TextareaProps, { isFormElement: boolean }>(
5557
});
5658
const { isFieldSetColumn } = useContext(FieldSetColumnContext);
5759
const taClassNames = classnames(className, 'slds-input');
58-
const textareaElem = (
60+
const textareaElem = readOnly ? (
61+
<Text type='regular' category='body'>
62+
{rprops.value}
63+
</Text>
64+
) : (
5965
<textarea
6066
id={id}
6167
ref={textareaRef}
@@ -74,6 +80,7 @@ export const Textarea = createFC<TextareaProps, { isFormElement: boolean }>(
7480
tooltip,
7581
tooltipIcon,
7682
elementRef,
83+
readOnly,
7784
};
7885
return <FormElement {...formElemProps}>{textareaElem}</FormElement>;
7986
}

0 commit comments

Comments
 (0)