From 6a8c5e5568c953ada35c7a2c5d9ba16197257d7f Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Mon, 30 Mar 2020 17:44:29 -0400 Subject: [PATCH] Add an onBlur handler for the kuery bar. Only resubmit when input changes. --- .../components/functional/kuery_bar/typeahead/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/index.js b/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/index.js index 9b8bdb50441c9..0ea5e1e2b8372 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/index.js +++ b/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/index.js @@ -27,6 +27,7 @@ export class Typeahead extends Component { index: null, value: '', inputIsPristine: true, + lastSubmitted: '', }; static getDerivedStateFromProps(props, state) { @@ -151,7 +152,10 @@ export class Typeahead extends Component { }; onSubmit = () => { - this.props.onSubmit(this.state.value); + if (this.state.lastSubmitted !== this.state.value) { + this.props.onSubmit(this.state.value); + this.setState({ lastSubmitted: this.state.value }); + } this.setState({ isSuggestionsVisible: false }); }; @@ -177,6 +181,7 @@ export class Typeahead extends Component { value={this.state.value} onKeyDown={this.onKeyDown} onKeyUp={this.onKeyUp} + onBlur={this.onSubmit} onChange={this.onChangeInputValue} onClick={this.onClickInput} autoComplete="off"