Skip to content

Commit e08cf61

Browse files
authored
Add an onBlur handler for the kuery bar. Only resubmit when input changes. (#61901) (#62031)
1 parent a9cd868 commit e08cf61

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead

x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class Typeahead extends Component {
2727
index: null,
2828
value: '',
2929
inputIsPristine: true,
30+
lastSubmitted: '',
3031
};
3132

3233
static getDerivedStateFromProps(props, state) {
@@ -151,7 +152,10 @@ export class Typeahead extends Component {
151152
};
152153

153154
onSubmit = () => {
154-
this.props.onSubmit(this.state.value);
155+
if (this.state.lastSubmitted !== this.state.value) {
156+
this.props.onSubmit(this.state.value);
157+
this.setState({ lastSubmitted: this.state.value });
158+
}
155159
this.setState({ isSuggestionsVisible: false });
156160
};
157161

@@ -177,6 +181,7 @@ export class Typeahead extends Component {
177181
value={this.state.value}
178182
onKeyDown={this.onKeyDown}
179183
onKeyUp={this.onKeyUp}
184+
onBlur={this.onSubmit}
180185
onChange={this.onChangeInputValue}
181186
onClick={this.onClickInput}
182187
autoComplete="off"

0 commit comments

Comments
 (0)