Skip to content

Commit 2c95be4

Browse files
authored
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
1 parent 77cabba commit 2c95be4

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/main/src/ComboBox.js

+15
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ class ComboBox extends UI5Element {
323323

324324
this._filteredItems = [];
325325
this._initialRendering = true;
326+
this._itemFocused = false;
326327
this.i18nBundle = getI18nBundle("@ui5/webcomponents");
327328
}
328329

@@ -356,6 +357,16 @@ class ComboBox extends UI5Element {
356357
// Set initial focus to the native input
357358
this.inner.focus();
358359
}
360+
361+
if (this.shouldClosePopover()) {
362+
this.responsivePopover.close(false, false, true);
363+
}
364+
365+
this._itemFocused = false;
366+
}
367+
368+
shouldClosePopover() {
369+
return this.responsivePopover.opened && !this.focused && !this._itemFocused;
359370
}
360371

361372
_focusin(event) {
@@ -508,6 +519,10 @@ class ComboBox extends UI5Element {
508519
this._inputChange();
509520
}
510521

522+
_onItemFocus(event) {
523+
this._itemFocused = true;
524+
}
525+
511526
get _headerTitleText() {
512527
return this.i18nBundle.getText(INPUT_SUGGESTIONS_TITLE);
513528
}

packages/main/src/ComboBoxPopover.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<ui5-list
5050
separators="None"
5151
@ui5-item-click={{_selectItem}}
52+
@ui5-item-focused={{_onItemFocus}}
5253
mode="SingleSelect"
5354
>
5455
{{#each _filteredItems}}

0 commit comments

Comments
 (0)