Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Text area): Add resize disable feature #11383

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/react-core/src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { FormControlIcon } from '../FormControl/FormControlIcon';
export enum TextAreResizeOrientation {
horizontal = 'horizontal',
vertical = 'vertical',
both = 'both'
both = 'both',
none = 'none'
}

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

return (
Expand All @@ -130,7 +131,7 @@ class TextAreaBase extends React.Component<TextAreaProps> {
styles.formControl,
readOnlyVariant && styles.modifiers.readonly,
readOnlyVariant === 'plain' && styles.modifiers.plain,
resizeOrientation && styles.modifiers[orientation],
resizeOrientation !== 'none' && styles.modifiers[orientation],
isDisabled && styles.modifiers.disabled,
hasStatusIcon && styles.modifiers[validated as 'success' | 'warning' | 'error'],
className
Expand Down
Loading