Skip to content

Commit 76ef62c

Browse files
authored
fix(ui5-multi-combobox): correct focus handling when picker is opened via icon (#2868)
1 parent 17cb758 commit 76ef62c

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

packages/main/src/MultiComboBox.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,11 @@ class MultiComboBox extends UI5Element {
428428
}
429429

430430
togglePopover() {
431-
this._toggleRespPopover();
432-
433431
if (!isPhone()) {
434432
this._inputDom.focus();
435433
}
434+
435+
this._toggleRespPopover();
436436
}
437437

438438
filterSelectedItems(event) {

packages/main/test/pages/MultiComboBox.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
<span>value state success </span>
132132

133133
<br>
134-
<ui5-multi-combobox allow-custom-values placeholder="Some initial text"
134+
<ui5-multi-combobox id="mcb-success" allow-custom-values placeholder="Some initial text"
135135
value-state="Success">
136136
<ui5-mcb-item selected text="Cosy"></ui5-mcb-item>
137137
<ui5-mcb-item text="Compact"></ui5-mcb-item>

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

+16-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ describe("MultiComboBox general interaction", () => {
1616
assert.ok(!popover.getProperty("opened"), "Popover should close");
1717
});
1818

19-
/*
2019
it("Checks focus state", () => {
2120
const mcb = browser.$("#multi1");
2221
const input = mcb.shadow$("#ui5-multi-combobox-input");
@@ -35,7 +34,6 @@ describe("MultiComboBox general interaction", () => {
3534

3635
assert.ok(mcb.getProperty("focused"), "MultiComboBox should be focused again.");
3736
});
38-
*/
3937

4038
it("MultiComboBox open property is set correctly", () => {
4139
const mcb = browser.$("#multi1");
@@ -111,6 +109,21 @@ describe("MultiComboBox general interaction", () => {
111109
resetBtn.click();
112110
});
113111

112+
it("When popover is opened via icon and item is selected/deselected, focus should return to the MultiComboBox", () => {
113+
const icon = browser.$("#mcb-success").shadow$("[input-icon]");
114+
const staticAreaItemClassName = browser.getStaticAreaItemClassName("#mcb-success")
115+
const popover = browser.$(`.${staticAreaItemClassName}`).shadow$(".ui5-multi-combobox-all-items-responsive-popover");
116+
const firstItem = popover.$(".ui5-multi-combobox-all-items-list > ui5-li");
117+
118+
icon.click();
119+
120+
assert.strictEqual(popover.getProperty("opened"), true, "The popover should be opened");
121+
122+
firstItem.click();
123+
124+
assert.ok(browser.$("#mcb-success").getProperty("focused"), "MultiComboBox should be focused.");
125+
});
126+
114127
it("Opens all items popover when start typing and filters items", () => {
115128
const input = browser.$("#mcb").shadow$("#ui5-multi-combobox-input");
116129
const staticAreaItemClassName = browser.getStaticAreaItemClassName("#mcb")
@@ -173,6 +186,7 @@ describe("MultiComboBox general interaction", () => {
173186

174187
assert.strictEqual(popover.getProperty("opened"), false, "When the content is clicked, the popover should close");
175188
assert.strictEqual(input.getValue(), "", "When the content is clicked, the value should be removed");
189+
assert.ok(browser.$("#another-mcb").getProperty("focused"), "MultiComboBox should be focused.");
176190
});
177191

178192
it("When item's checkbox is clicked, the popover should not be closed and the value in the input should be kept", () => {

0 commit comments

Comments
 (0)