Skip to content

Commit d5a574c

Browse files
authored
fix(ui5-select): use accessibleName for option announcements (#13202)
Problem: - When accessibleName is set on select options, it is not read out by screen readers. Solution: - Use the accessibleName property when available, falling back to textContent for announcements. - Also added a test and updated chromedriver to 145.0.0 Fixes: #11809
1 parent 9c02c2b commit d5a574c

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

packages/main/src/Select.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ interface IOption extends UI5Element {
8888
text?: Array<Node>,
8989
stableDomRef: string,
9090
displayText?: string,
91+
accessibleName?: string,
9192
}
9293

9394
type SelectChangeEventDetail = {
@@ -1110,7 +1111,8 @@ class Select extends UI5Element implements IFormElement {
11101111
const itemPositionText = Select.i18nBundle.getText(LIST_ITEM_POSITION, this._selectedIndex + 1, optionsCount);
11111112

11121113
if (this.focused && this._currentlySelectedOption) {
1113-
text = `${this._currentlySelectedOption.textContent as string} ${this._isPickerOpen ? itemPositionText : ""}`;
1114+
const optionText = this._currentlySelectedOption.getAttribute("accessible-name") || this._currentlySelectedOption.textContent as string;
1115+
text = `${optionText}${this._isPickerOpen ? `, ${itemPositionText}` : ""}`;
11141116

11151117
announce(text, InvisibleMessageMode.Polite);
11161118
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,20 @@ describe("Select Menu general interaction", () => {
150150

151151
assert.strictEqual(await inpTestChange.getProperty("value"), "1", "Change event should be fired after focus out");
152152
});
153+
154+
it("Tests accessible-name on SelectMenuOption", async () => {
155+
const menu = await browser.$("#selectOptions");
156+
const options = await menu.$$("ui5-select-menu-option");
157+
158+
const EXPECTED_FIRST_OPTION_ACCESSIBLE_NAME = "T-shirt size S";
159+
const EXPECTED_SECOND_OPTION_ACCESSIBLE_NAME = "Dress size M";
160+
const EXPECTED_THIRD_OPTION_ACCESSIBLE_NAME = "Skirt size L";
161+
162+
assert.strictEqual(await options[0].getProperty("accessibleName"), EXPECTED_FIRST_OPTION_ACCESSIBLE_NAME,
163+
"The accessible-name property on first ui5-select-menu-option is correctly set.");
164+
assert.strictEqual(await options[1].getProperty("accessibleName"), EXPECTED_SECOND_OPTION_ACCESSIBLE_NAME,
165+
"The accessible-name property on second ui5-select-menu-option is correctly set.");
166+
assert.strictEqual(await options[2].getProperty("accessibleName"), EXPECTED_THIRD_OPTION_ACCESSIBLE_NAME,
167+
"The accessible-name property on third ui5-select-menu-option is correctly set.");
168+
});
153169
});

0 commit comments

Comments
 (0)