Skip to content

Commit

Permalink
Add an onBlur handler for the kuery bar. Only resubmit when input cha…
Browse files Browse the repository at this point in the history
…nges. (#61901) (#62031)
  • Loading branch information
justinkambic authored Mar 31, 2020
1 parent a9cd868 commit e08cf61
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class Typeahead extends Component {
index: null,
value: '',
inputIsPristine: true,
lastSubmitted: '',
};

static getDerivedStateFromProps(props, state) {
Expand Down Expand Up @@ -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 });
};

Expand All @@ -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"
Expand Down

0 comments on commit e08cf61

Please sign in to comment.