diff --git a/CHANGELOG.md b/CHANGELOG.md index eaafa696ed4..8d846cb480b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -**Note: this release is a backport containing changes originally made in `9.0.0`** +**Note: this release is a backport containing changes originally made in `9.0.0` and `9.1.0`** **Bug fixes** - Fixed keyboard navigation and UI of `EuiComboBox` items in single selection mode ([#1619](https://github.com/elastic/eui/pull/1619)) +- Fixed `EuiComboBox` `activeOptonIndex` error with empty search results ([#1695](https://github.com/elastic/eui/pull/1695)) ## [`6.10.4`](https://github.com/elastic/eui/tree/v6.10.4) diff --git a/src/components/combo_box/__snapshots__/combo_box.test.js.snap b/src/components/combo_box/__snapshots__/combo_box.test.js.snap index 40176609338..54b0198f286 100644 --- a/src/components/combo_box/__snapshots__/combo_box.test.js.snap +++ b/src/components/combo_box/__snapshots__/combo_box.test.js.snap @@ -451,6 +451,7 @@ exports[`props singleSelection selects existing option when opened 1`] = ` /> { let nextActiveOptionIndex; - if (activeOptionIndex == null) { + if (activeOptionIndex < 0) { // If this is the beginning of the user's keyboard navigation of the menu, then we'll focus // either the first or last item. nextActiveOptionIndex = amount < 0 ? matchingOptions.length - 1 : 0; @@ -186,12 +186,12 @@ export class EuiComboBox extends Component { }; hasActiveOption = () => { - return this.state.activeOptionIndex != null && this.state.activeOptionIndex < this.state.matchingOptions.length; + return this.state.activeOptionIndex > -1 && this.state.activeOptionIndex < this.state.matchingOptions.length; }; clearActiveOption = () => { this.setState({ - activeOptionIndex: undefined, + activeOptionIndex: -1, }); }; @@ -498,7 +498,7 @@ export class EuiComboBox extends Component { const stateUpdate = { matchingOptions }; if (activeOptionIndex >= matchingOptions.length) { - stateUpdate.activeOptionIndex = undefined; + stateUpdate.activeOptionIndex = -1; } return stateUpdate;