Skip to content

Commit 08ea794

Browse files
authored
fix(ui5-multi-combobox): add value selection on focus (#4804)
1 parent f93f22f commit 08ea794

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

packages/main/src/MultiComboBox.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ class MultiComboBox extends UI5Element {
10351035
this._innerInput.blur();
10361036
}
10371037

1038+
!isPhone() && this._innerInput.setSelectionRange(0, this.value.length);
10381039
this._lastValue = this.value;
10391040
}
10401041

packages/main/test/pages/MultiComboBox.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@
8686
</ui5-multi-combobox>
8787
</div>
8888

89+
<div class="demo-section">
90+
<span>allow-custom-values and predefined value</span>
91+
92+
<br>
93+
<ui5-multi-combobox id="multi-acv" allow-custom-values value="com">
94+
<ui5-mcb-item selected text="Cosy"></ui5-mcb-item>
95+
<ui5-mcb-item text="Compact"></ui5-mcb-item>
96+
<ui5-mcb-item text="Condensed"></ui5-mcb-item>
97+
</ui5-multi-combobox>
98+
</div>
99+
89100
<div class="demo-section">
90101
<span>Validating input and placeholder </span>
91102

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,32 @@ describe("MultiComboBox general interaction", () => {
684684
await browser.url(`http://localhost:${PORT}/test-resources/pages/MultiComboBox.html`);
685685
});
686686

687+
it ("tests text selection on focus", async () => {
688+
const mcb = await browser.$("#multi-acv");
689+
const mcb2 = await browser.$("#mcb-with-placeholder");
690+
691+
await mcb.click();
692+
693+
const selectionStartIndex = await browser.execute(() => {
694+
return document.querySelector("#multi-acv").shadowRoot.querySelector("input").selectionStart;
695+
});
696+
const selectionEndIndex = await browser.execute(() => {
697+
return document.querySelector("#multi-acv").shadowRoot.querySelector("input").selectionEnd;
698+
});
699+
700+
assert.equal(await selectionStartIndex, 0, "The selection starts from the beginning of the value");
701+
assert.equal(await selectionEndIndex, 3, "The whole value is selected");
702+
703+
await mcb.keys("Tab");
704+
assert.equal(await mcb2.getProperty("focused"), true, "The next control is focused");
705+
706+
await mcb2.keys(["Shift", "Tab"]);
707+
assert.equal(await selectionStartIndex, 0, "The selection starts from the beginning of the value");
708+
assert.equal(await selectionEndIndex, 3, "The whole value is selected");
709+
710+
711+
});
712+
687713
it ("tests two-column layout", async () => {
688714
const mcb = await browser.$("#mcb-two-column-layout");
689715
const staticAreaItemClassName = await browser.getStaticAreaItemClassName("#mcb-two-column-layout");

0 commit comments

Comments
 (0)