From 2c95be453475472480483abcae7faaa24fbe6c5b Mon Sep 17 00:00:00 2001 From: ilhan orhan Date: Mon, 27 Jul 2020 17:58:57 +0300 Subject: [PATCH] fix(ui5-combobox): Close popup on focusout (#2013) Now the popup closes on focusout, except the case when the focusout is due to focusin of the items FIXES: #2009 --- packages/main/src/ComboBox.js | 15 +++++++++++++++ packages/main/src/ComboBoxPopover.hbs | 1 + 2 files changed, 16 insertions(+) diff --git a/packages/main/src/ComboBox.js b/packages/main/src/ComboBox.js index 5aea103ba53d..6f72858988d3 100644 --- a/packages/main/src/ComboBox.js +++ b/packages/main/src/ComboBox.js @@ -323,6 +323,7 @@ class ComboBox extends UI5Element { this._filteredItems = []; this._initialRendering = true; + this._itemFocused = false; this.i18nBundle = getI18nBundle("@ui5/webcomponents"); } @@ -356,6 +357,16 @@ class ComboBox extends UI5Element { // Set initial focus to the native input this.inner.focus(); } + + if (this.shouldClosePopover()) { + this.responsivePopover.close(false, false, true); + } + + this._itemFocused = false; + } + + shouldClosePopover() { + return this.responsivePopover.opened && !this.focused && !this._itemFocused; } _focusin(event) { @@ -508,6 +519,10 @@ class ComboBox extends UI5Element { this._inputChange(); } + _onItemFocus(event) { + this._itemFocused = true; + } + get _headerTitleText() { return this.i18nBundle.getText(INPUT_SUGGESTIONS_TITLE); } diff --git a/packages/main/src/ComboBoxPopover.hbs b/packages/main/src/ComboBoxPopover.hbs index 7807f1788b36..3c241fb02a7e 100644 --- a/packages/main/src/ComboBoxPopover.hbs +++ b/packages/main/src/ComboBoxPopover.hbs @@ -49,6 +49,7 @@ {{#each _filteredItems}}