Skip to content

Commit fef8110

Browse files
d3xter666ilhan007
authored andcommitted
fix(ui5-combobox): Properly focus inner input (#3243)
FIXES: #2895
1 parent 5d62888 commit fef8110

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

packages/main/src/ComboBox.hbs

Lines changed: 1 addition & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

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

0 commit comments

Comments
 (0)