From 57454f9aa96809a54259f31f6339e3ad147d7269 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 8 Mar 2019 08:10:34 +0100 Subject: [PATCH] adds option to request focus for a textarea --- .../packages/ui-components/src/forms/Textarea.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scm-ui-components/packages/ui-components/src/forms/Textarea.js b/scm-ui-components/packages/ui-components/src/forms/Textarea.js index 3db590122a..4ea3741a31 100644 --- a/scm-ui-components/packages/ui-components/src/forms/Textarea.js +++ b/scm-ui-components/packages/ui-components/src/forms/Textarea.js @@ -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 { field: ?HTMLTextAreaElement; + componentDidMount() { + if (this.props.autofocus && this.field) { + this.field.focus(); + } + } + handleInput = (event: SyntheticInputEvent) => { this.props.onChange(event.target.value, this.props.name); };