diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dae76687ed..313ae08905f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Adds missing type and fixes closure-scope problem for `SuperDatePicker`'s `onRefresh` callback ([#1732](https://github.com/elastic/eui/pull/1732)) - Changed `EuiBottomBar` to refer to the end of document ([#1727](https://github.com/elastic/eui/pull/1727)) +- Fixed `EuiComboBox`'s calls to its `onBlur` prop ([#1739](https://github.com/elastic/eui/pull/1739)) ## [`9.4.0`](https://github.com/elastic/eui/tree/v9.4.0) diff --git a/src/components/combo_box/combo_box.js b/src/components/combo_box/combo_box.js index 2efa74e7575..da0003aacb3 100644 --- a/src/components/combo_box/combo_box.js +++ b/src/components/combo_box/combo_box.js @@ -286,19 +286,20 @@ export class EuiComboBox extends Component { const focusedInInput = this.comboBox && this.comboBox.contains(e.relatedTarget); if (!focusedInOptionsList && !focusedInInput) { this.closeList(); - } - // If the user tabs away or changes focus to another element, take whatever input they've - // typed and convert it into a pill, to prevent the combo box from looking like a text input. - if (!this.hasActiveOption() && !focusedInInput && !focusedInOptionsList) { - this.addCustomOption(); + if (this.props.onBlur) { + this.props.onBlur(); + } + + // If the user tabs away or changes focus to another element, take whatever input they've + // typed and convert it into a pill, to prevent the combo box from looking like a text input. + if (!this.hasActiveOption()) { + this.addCustomOption(); + } } } onComboBoxBlur = () => { - if (this.props.onBlur) { - this.props.onBlur(); - } this.setState({ hasFocus: false }); } @@ -571,6 +572,7 @@ export class EuiComboBox extends Component { onChange, // eslint-disable-line no-unused-vars onSearchChange, // eslint-disable-line no-unused-vars async, // eslint-disable-line no-unused-vars + onBlur, // eslint-disable-line no-unused-vars isInvalid, rowHeight, isClearable,