Skip to content

Commit 3828124

Browse files
authored
docs(TextArea): add onFocus/onBlur props to table (#9513)
* docs(TextArea): add onFocus/onBlur props to table * update event typing
1 parent c1d4b99 commit 3828124

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export interface TextAreaProps extends Omit<HTMLProps<HTMLTextAreaElement>, 'onC
3636
value?: string | number;
3737
/** A callback for when the text area value changes. */
3838
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, value: string) => void;
39+
/** Callback function when text area is focused */
40+
onFocus?: (event?: React.FocusEvent<HTMLTextAreaElement>) => void;
41+
/** Callback function when text area is blurred (focus leaves) */
42+
onBlur?: (event?: React.FocusEvent<HTMLTextAreaElement>) => void;
3943
/** Sets the orientation to limit the resize to */
4044
resizeOrientation?: 'horizontal' | 'vertical' | 'both';
4145
/** Custom flag to show that the text area requires an associated id or aria-label. */
@@ -114,6 +118,8 @@ class TextAreaBase extends React.Component<TextAreaProps> {
114118
autoResize,
115119
onChange,
116120
/* eslint-enable @typescript-eslint/no-unused-vars */
121+
onBlur,
122+
onFocus,
117123
...props
118124
} = this.props;
119125
const orientation = `resize${capitalize(resizeOrientation)}` as
@@ -136,6 +142,8 @@ class TextAreaBase extends React.Component<TextAreaProps> {
136142
>
137143
<textarea
138144
onChange={this.handleChange}
145+
onFocus={onFocus}
146+
onBlur={onBlur}
139147
{...(typeof this.props.defaultValue !== 'string' && { value })}
140148
aria-invalid={validated === ValidatedOptions.error}
141149
required={isRequired}

0 commit comments

Comments
 (0)