mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
adds option to request focus for a textarea
This commit is contained in:
@@ -12,6 +12,7 @@ type Props = {
|
||||
label?: string,
|
||||
placeholder?: SelectItem[],
|
||||
value?: string,
|
||||
autofocus?: boolean,
|
||||
onChange: (value: string, name?: string) => void,
|
||||
helpText?: string
|
||||
};
|
||||
@@ -19,6 +20,12 @@ type Props = {
|
||||
class Textarea extends React.Component<Props> {
|
||||
field: ?HTMLTextAreaElement;
|
||||
|
||||
componentDidMount() {
|
||||
if (this.props.autofocus && this.field) {
|
||||
this.field.focus();
|
||||
}
|
||||
}
|
||||
|
||||
handleInput = (event: SyntheticInputEvent<HTMLTextAreaElement>) => {
|
||||
this.props.onChange(event.target.value, this.props.name);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user