Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
- need to call `onSearchChange` after matchingOptions state update in `getDerivedStateFromProps` runs, instead of before
  • Loading branch information
cee-chen committed Nov 1, 2023
1 parent f0ec473 commit 352cf45
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/combo_box/combo_box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -638,13 +638,14 @@ export class EuiComboBox<T> extends Component<
) => {
const { onSearchChange, delimiter } = this.props;

if (onSearchChange) {
const hasMatchingOptions = this.state.matchingOptions.length > 0;
onSearchChange(searchValue, hasMatchingOptions);
}

this.setState({ searchValue }, () => {
if (searchValue && this.state.isListOpen === false) this.openList();
if (searchValue && this.state.isListOpen === false) {
this.openList();
}
if (onSearchChange) {
const hasMatchingOptions = this.state.matchingOptions.length > 0;
onSearchChange(searchValue, hasMatchingOptions);
}
});
if (delimiter && searchValue.endsWith(delimiter)) {
this.setCustomOptions(false);
Expand Down

0 comments on commit 352cf45

Please sign in to comment.