Skip to content

Commit 23fb8b7

Browse files
authored
fix(ui5-combobox): corrected display of items in popover
Now, all items are shown inside ui5-popover when it is opened and items are filtered only on user input. Fixes: #1925
1 parent a3207e5 commit 23fb8b7

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

packages/main/src/ComboBox.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,14 @@ class ComboBox extends UI5Element {
327327
}
328328

329329
onBeforeRendering() {
330-
const domValue = this._initialRendering ? this.value : this.filterValue;
330+
let domValue;
331331

332-
this._filteredItems = this._filterItems(domValue);
332+
if (this._initialRendering) {
333+
domValue = this.value;
334+
this._filteredItems = this.items;
335+
} else {
336+
domValue = this.filterValue;
337+
}
333338

334339
if (this._autocomplete && domValue !== "") {
335340
this._autoCompleteValue(domValue);
@@ -502,12 +507,6 @@ class ComboBox extends UI5Element {
502507
this._closeRespPopover();
503508
}
504509

505-
get _filteredItems() {
506-
return !this.items.length ? [] : this.items.filter(item => {
507-
return item.text.toLowerCase().startsWith(this.value.toLowerCase());
508-
});
509-
}
510-
511510
get _headerTitleText() {
512511
return this.i18nBundle.getText(INPUT_SUGGESTIONS_TITLE);
513512
}

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

+26
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,32 @@ describe("General interaction", () => {
1717
assert.ok(popover.getProperty("opened"), "Popover should be displayed")
1818
});
1919

20+
it ("Items filtration", () => {
21+
browser.url("http://localhost:8080/test-resources/pages/ComboBox.html");
22+
23+
const combo = $("#combo");
24+
const arrow = combo.shadow$("[input-icon]");
25+
const input = combo.shadow$("#ui5-combobox-input");
26+
const staticAreaItemClassName = browser.getStaticAreaItemClassName("#combo");
27+
const popover = browser.$(`.${staticAreaItemClassName}`).shadow$("ui5-responsive-popover");
28+
let listItems = popover.$("ui5-list").$$("ui5-li");
29+
30+
// act
31+
arrow.click();
32+
33+
// assert
34+
assert.strictEqual(listItems.length, 11, "All items are shown with selected item");
35+
36+
// act
37+
input.click();
38+
browser.keys("Backspace");
39+
40+
// assert
41+
listItems = popover.$("ui5-list").$$("ui5-li");
42+
assert.strictEqual(listItems.length, 1, "Items are filtered on input value change");
43+
44+
});
45+
2046
it ("Should open the popover when typing a value", () => {
2147
browser.url("http://localhost:8080/test-resources/pages/ComboBox.html");
2248

0 commit comments

Comments
 (0)