Skip to content

Commit 68cb73d

Browse files
authored
fix(ui5-mcb): open correct popover from show more text (#1371)
FIXES: #1359
1 parent a7cf983 commit 68cb73d

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

packages/main/src/MultiComboBox.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ class MultiComboBox extends UI5Element {
527527
_toggleRespPopover(isMorePopover) {
528528
this.updateStaticAreaItemContentDensity();
529529

530+
if (isMorePopover) {
531+
this.allItemsPopover.close();
532+
return this.selectedItemsPopover.open(this);
533+
}
534+
530535
if (this.allItemsPopover && this.allItemsPopover.opened) {
531536
return this.allItemsPopover.close();
532537
}
@@ -561,13 +566,18 @@ class MultiComboBox extends UI5Element {
561566
}
562567

563568
_toggleButtonPress(event) {
564-
if (this._selectedItemsPopoverOpened) {
565-
event.target.pressed = true;
566-
this._showAllItemsPopover();
569+
const showSelectedItems = event.target.hasAttribute("show-selected");
570+
571+
if (showSelectedItems) {
572+
this.allItemsPopover.close();
573+
this.selectedItemsPopover.open(this);
567574
} else {
568-
event.target.pressed = false;
569-
this._showMorePopover();
575+
this.selectedItemsPopover.close();
576+
this.allItemsPopover.open(this);
570577
}
578+
579+
// always keep the toggle-button pressed
580+
event.target.pressed = true;
571581
}
572582

573583
onBeforeRendering() {

packages/main/src/MultiComboBoxPopover.hbs

+3-2
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,14 @@
106106
aria-describedby="{{_id}}-valueStateDesc"
107107
/>
108108
</div>
109-
<ui5-togglebutton
109+
<ui5-button
110110
slot="header"
111111
class="ui5-multi-combobox-toggle-button"
112112
icon="multiselect-all"
113113
design="Transparent"
114114
@click="{{_toggleButtonPress}}"
115-
></ui5-togglebutton>
115+
show-selected
116+
></ui5-button>
116117
</div>
117118
</div>
118119

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

+20-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,27 @@ describe("MultiComboBox general interaction", () => {
3737

3838
resetBtn.click();
3939
});
40+
41+
it("Opens selected items Popover", () => {
42+
browser.url("http://localhost:8080/test-resources/pages/MultiComboBox.html");
43+
44+
browser.setWindowSize(400, 1250);
45+
const staticAreaItemClassName = browser.getStaticAreaItemClassName("#multi1")
46+
const showMore = $("#multi1").shadow$(".ui5-multi-combobox-tokenizer").shadow$(".ui5-tokenizer-more-text");
47+
const allPopover = $(`.${staticAreaItemClassName}`).shadow$(".ui5-multi-combobox-all-items-responsive-popover");
48+
const selectedPopover = $(`.${staticAreaItemClassName}`).shadow$(".ui5-multi-combobox-selected-items-responsive-popover");
49+
50+
showMore.click();
51+
52+
assert.ok(!allPopover.getProperty("opened"), "All popover should not be displayed");
53+
assert.ok(selectedPopover.getProperty("opened"), "All popover should be displayed");
54+
});
4055
});
4156

4257
describe("selection and filtering", () => {
58+
browser.url("http://localhost:8080/test-resources/pages/MultiComboBox.html");
59+
browser.setWindowSize(1920, 1080);
60+
4361

4462
it("Opens all items popover, selects and deselects the first item", () => {
4563
const icon = browser.$("#mcb").shadow$("[input-icon]");
@@ -51,7 +69,7 @@ describe("MultiComboBox general interaction", () => {
5169
const paramsInput = $("#events-parameters");
5270
const callCountInput = $("#events-call-count");
5371
const resetBtn = $("#reset-btn");
54-
72+
5573
icon.click();
5674

5775
assert.ok(popover.getProperty("opened"), "Popover should be displayed in the viewport");
@@ -168,7 +186,7 @@ describe("MultiComboBox general interaction", () => {
168186
describe("keyboard handling", () => {
169187
browser.url("http://localhost:8080/test-resources/pages/MultiComboBox.html");
170188

171-
it ("tests backspace when combobox has an empty value", () => {
189+
it("tests backspace when combobox has an empty value", () => {
172190
let tokens = $("#multi1").shadow$$(".ui5-multi-combobox-token");
173191
const input = $("#multi1").shadow$("input");
174192

0 commit comments

Comments
 (0)