Add an onBlur handler for the kuery bar. Only resubmit when input changes. (#61901) (#62031)

This commit is contained in:
Justin Kambic 2020-03-31 16:57:06 -04:00 committed by GitHub
parent a9cd868dd8
commit e08cf61bcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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"