Skip to content

Commit

Permalink
fix(ui5-combo-box): Close picker when no match (#1926)
Browse files Browse the repository at this point in the history
When the user types and there is no match, the picker remains open and empty, now it closes.

FIXES: #1920
  • Loading branch information
ilhan007 committed Jul 8, 2020
1 parent cd2f9bf commit dcac133
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/main/src/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,13 @@ class ComboBox extends UI5Element {
this.filterValue = value;
this.fireEvent("input");

this._openRespPopover();
this._filteredItems = this._filterItems(value);

if (!this._filteredItems.length) {
this._closeRespPopover();
} else {
this._openRespPopover();
}
}

_startsWithMatchingItems(str) {
Expand Down
16 changes: 16 additions & 0 deletions packages/main/test/specs/ComboBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,33 @@ describe("General interaction", () => {
const popover = browser.$(`.${staticAreaItemClassName}`).shadow$("ui5-responsive-popover");
let listItems = popover.$("ui5-list").$$("ui5-li");

// act
arrow.click();

// assert
assert.strictEqual(listItems.length, 11, "Items should be 11");

// act
input.keys("a");

// assert
listItems = popover.$("ui5-list").$$("ui5-li");
assert.strictEqual(listItems.length, 5, "Items should be 5");

// act
input.keys("u");

// assert
listItems = popover.$("ui5-list").$$("ui5-li");
assert.strictEqual(listItems.length, 2, "Items should be 2");

// act
input.keys("zzz");
listItems = popover.$("ui5-list").$$("ui5-li");

// assert
assert.strictEqual(listItems.length, 0, "Items should be 0");
assert.notOk(popover.getProperty("opened"), "Popover should close");
});

it ("Tests change event", () => {
Expand Down

0 comments on commit dcac133

Please sign in to comment.