adds option to request focus for a textarea

This commit is contained in:
Sebastian Sdorra
2019-03-08 08:10:34 +01:00
parent 7729960a00
commit 57454f9aa9

View File

@@ -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);
};