Skip to content

Commit dcac133

Browse files
authored
fix(ui5-combo-box): Close picker when no match (#1926)
When the user types and there is no match, the picker remains open and empty, now it closes. FIXES: #1920
1 parent cd2f9bf commit dcac133

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

packages/main/src/ComboBox.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,13 @@ class ComboBox extends UI5Element {
411411
this.filterValue = value;
412412
this.fireEvent("input");
413413

414-
this._openRespPopover();
414+
this._filteredItems = this._filterItems(value);
415+
416+
if (!this._filteredItems.length) {
417+
this._closeRespPopover();
418+
} else {
419+
this._openRespPopover();
420+
}
415421
}
416422

417423
_startsWithMatchingItems(str) {

packages/main/test/specs/ComboBox.spec.js

+16
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,33 @@ describe("General interaction", () => {
5757
const popover = browser.$(`.${staticAreaItemClassName}`).shadow$("ui5-responsive-popover");
5858
let listItems = popover.$("ui5-list").$$("ui5-li");
5959

60+
// act
6061
arrow.click();
6162

63+
// assert
6264
assert.strictEqual(listItems.length, 11, "Items should be 11");
6365

66+
// act
6467
input.keys("a");
68+
69+
// assert
6570
listItems = popover.$("ui5-list").$$("ui5-li");
6671
assert.strictEqual(listItems.length, 5, "Items should be 5");
6772

73+
// act
6874
input.keys("u");
75+
76+
// assert
6977
listItems = popover.$("ui5-list").$$("ui5-li");
7078
assert.strictEqual(listItems.length, 2, "Items should be 2");
79+
80+
// act
81+
input.keys("zzz");
82+
listItems = popover.$("ui5-list").$$("ui5-li");
83+
84+
// assert
85+
assert.strictEqual(listItems.length, 0, "Items should be 0");
86+
assert.notOk(popover.getProperty("opened"), "Popover should close");
7187
});
7288

7389
it ("Tests change event", () => {

0 commit comments

Comments
 (0)