Skip to content

Commit 6f19754

Browse files
committed
feat(Text area): Add reasize disable feature
1 parent 6768c65 commit 6f19754

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/react-core/src/components/TextArea/TextArea.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { FormControlIcon } from '../FormControl/FormControlIcon';
88
export enum TextAreResizeOrientation {
99
horizontal = 'horizontal',
1010
vertical = 'vertical',
11-
both = 'both'
11+
both = 'both',
12+
disabled = 'disabled'
1213
}
1314

1415
export enum TextAreaReadOnlyVariant {
@@ -37,7 +38,7 @@ export interface TextAreaProps extends Omit<HTMLProps<HTMLTextAreaElement>, 'onC
3738
/** A callback for when the text area value changes. */
3839
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, value: string) => void;
3940
/** Sets the orientation to limit the resize to */
40-
resizeOrientation?: 'horizontal' | 'vertical' | 'both';
41+
resizeOrientation?: 'horizontal' | 'vertical' | 'both' | 'disabled';
4142
/** Custom flag to show that the text area requires an associated id or aria-label. */
4243
'aria-label'?: string;
4344
/** @hide A reference object to attach to the text area. */
@@ -118,10 +119,10 @@ class TextAreaBase extends React.Component<TextAreaProps> {
118119
onFocus,
119120
...props
120121
} = this.props;
121-
const orientation = `resize${capitalize(resizeOrientation)}` as
122-
| 'resizeVertical'
123-
| 'resizeHorizontal'
124-
| 'resizeBoth';
122+
const orientation =
123+
resizeOrientation !== 'disabled'
124+
? (`resize${capitalize(resizeOrientation)}` as 'resizeVertical' | 'resizeHorizontal' | 'resizeBoth')
125+
: undefined;
125126
const hasStatusIcon = ['success', 'error', 'warning'].includes(validated);
126127

127128
return (
@@ -130,7 +131,7 @@ class TextAreaBase extends React.Component<TextAreaProps> {
130131
styles.formControl,
131132
readOnlyVariant && styles.modifiers.readonly,
132133
readOnlyVariant === 'plain' && styles.modifiers.plain,
133-
resizeOrientation && styles.modifiers[orientation],
134+
resizeOrientation !== 'disabled' && styles.modifiers[orientation],
134135
isDisabled && styles.modifiers.disabled,
135136
hasStatusIcon && styles.modifiers[validated as 'success' | 'warning' | 'error'],
136137
className

0 commit comments

Comments
 (0)