diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-04-25 11:22:45 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-04-25 11:22:45 +0200 |
| commit | 31e5532f326596cf9f6d497bb72d1950ac207796 (patch) | |
| tree | 709fa5157b7f7c7b1e227eb566f0a657687f6475 | |
| parent | 86abfe8762fd071bfad3466152d78c5fbfb7df84 (diff) | |
| parent | 8cf5c9a5188b5fe828c7a29e24a367e38f32899e (diff) | |
| download | mullvadvpn-31e5532f326596cf9f6d497bb72d1950ac207796.tar.xz mullvadvpn-31e5532f326596cf9f6d497bb72d1950ac207796.zip | |
Merge branch 'blur-input-on-enter'
| -rw-r--r-- | gui/src/renderer/components/cell/Input.tsx | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gui/src/renderer/components/cell/Input.tsx b/gui/src/renderer/components/cell/Input.tsx index f464adf269..06553be624 100644 --- a/gui/src/renderer/components/cell/Input.tsx +++ b/gui/src/renderer/components/cell/Input.tsx @@ -79,6 +79,8 @@ export class Input extends React.Component<IInputProps, IInputState> { focused: false, }; + public inputRef = React.createRef<HTMLInputElement>(); + public componentDidUpdate(prevProps: IInputProps, _prevState: IInputState) { if ( !this.state.focused && @@ -118,6 +120,7 @@ export class Input extends React.Component<IInputProps, IInputState> { <CellDisabledContext.Consumer> {(disabled) => ( <StyledInput + ref={this.inputRef} type="text" valid={valid} aria-invalid={!valid} @@ -157,6 +160,7 @@ export class Input extends React.Component<IInputProps, IInputState> { private onKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => { if (event.key === 'Enter') { this.props.onSubmitValue?.(this.state.value); + this.inputRef.current?.blur(); } this.props.onKeyPress?.(event); }; |
