Skip to content

Commit

Permalink
fix(ui5-combobox): Properly focus inner input (#3243)
Browse files Browse the repository at this point in the history
FIXES: #2895
  • Loading branch information
d3xter666 authored Jul 7, 2021
1 parent 8580fd8 commit 790c02e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/main/src/ComboBox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
aria-describedby="{{valueStateTextId}}"
aria-label="{{ariaLabelText}}"
aria-required="{{required}}"
data-sap-focus-ref
/>

{{#if icon}}
Expand Down
5 changes: 5 additions & 0 deletions packages/main/test/pages/ComboBox.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<ui5-cb-item text="Canada"></ui5-cb-item>
<ui5-cb-item text="Chile"></ui5-cb-item>
</ui5-combobox>
<ui5-button id="combo-focus">Focus ComboBox</ui5-button>

<br>

Expand Down Expand Up @@ -276,6 +277,10 @@ <h3>ComboBox in Compact</h3>
document.getElementById("value-set-btn").addEventListener("click", function (event) {
document.getElementById("combo").value = "new value";
});

document.getElementById("combo-focus").addEventListener("click", function () {
document.getElementById("combo").focus();
});
</script>

</body>
Expand Down
11 changes: 11 additions & 0 deletions packages/main/test/specs/ComboBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,4 +492,15 @@ describe("Accessibility", () => {
assert.strictEqual(combo.getProperty("value"), "new value", "ComboBox value should be set to 'new value'");
assert.strictEqual(inner.getProperty("value"), "new value", "ComboBox value should be set to 'new value'");
});

it ("Should focus the ComboBox with the API", () => {
browser.url(`http://localhost:${PORT}/test-resources/pages/ComboBox.html`);

const combo = $("#combo");
const focusBtn = $("#combo-focus");

focusBtn.click();

assert.ok(combo.getProperty("focused"), "ComboBox to be focused");
});
});

0 comments on commit 790c02e

Please sign in to comment.