Skip to content

Commit 790c02e

Browse files
authored
fix(ui5-combobox): Properly focus inner input (#3243)
FIXES: #2895
1 parent 8580fd8 commit 790c02e

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

packages/main/src/ComboBox.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
aria-describedby="{{valueStateTextId}}"
2424
aria-label="{{ariaLabelText}}"
2525
aria-required="{{required}}"
26+
data-sap-focus-ref
2627
/>
2728

2829
{{#if icon}}

packages/main/test/pages/ComboBox.html

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<ui5-cb-item text="Canada"></ui5-cb-item>
5555
<ui5-cb-item text="Chile"></ui5-cb-item>
5656
</ui5-combobox>
57+
<ui5-button id="combo-focus">Focus ComboBox</ui5-button>
5758

5859
<br>
5960

@@ -276,6 +277,10 @@ <h3>ComboBox in Compact</h3>
276277
document.getElementById("value-set-btn").addEventListener("click", function (event) {
277278
document.getElementById("combo").value = "new value";
278279
});
280+
281+
document.getElementById("combo-focus").addEventListener("click", function () {
282+
document.getElementById("combo").focus();
283+
});
279284
</script>
280285

281286
</body>

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

+11
Original file line numberDiff line numberDiff line change
@@ -492,4 +492,15 @@ describe("Accessibility", () => {
492492
assert.strictEqual(combo.getProperty("value"), "new value", "ComboBox value should be set to 'new value'");
493493
assert.strictEqual(inner.getProperty("value"), "new value", "ComboBox value should be set to 'new value'");
494494
});
495+
496+
it ("Should focus the ComboBox with the API", () => {
497+
browser.url(`http://localhost:${PORT}/test-resources/pages/ComboBox.html`);
498+
499+
const combo = $("#combo");
500+
const focusBtn = $("#combo-focus");
501+
502+
focusBtn.click();
503+
504+
assert.ok(combo.getProperty("focused"), "ComboBox to be focused");
505+
});
495506
});

0 commit comments

Comments
 (0)