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.
  • Loading branch information
justinkambic committed Mar 30, 2020
1 parent 9ff8be6 commit 6a8c5e5
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 6a8c5e5

Please sign in to comment.