Skip to content

Commit

Permalink
feat(ui5-select): add aria-roledescription attribute (#4921)
Browse files Browse the repository at this point in the history
Closes: #2910
  • Loading branch information
dobrinyonkov authored and ilhan007 committed Mar 22, 2022
1 parent 2f40bd7 commit e4fa811
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/main/src/Select.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
aria-disabled="{{isDisabled}}"
aria-required="{{required}}"
aria-expanded="{{_isPickerOpen}}"
aria-roledescription="{{_ariaRoleDescription}}"
@keydown="{{_onkeydown}}"
@keypress="{{_handleKeyboardNavigation}}"
@keyup="{{_onkeyup}}"
Expand Down
5 changes: 5 additions & 0 deletions packages/main/src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
VALUE_STATE_WARNING,
INPUT_SUGGESTIONS_TITLE,
LIST_ITEM_POSITION,
SELECT_ROLE_DESCRIPTION,
} from "./generated/i18n/i18n-defaults.js";
import Option from "./Option.js";
import Label from "./Label.js";
Expand Down Expand Up @@ -768,6 +769,10 @@ class Select extends UI5Element {
&& !this._isPickerOpen && !this._isPhone;
}

get _ariaRoleDescription() {
return Select.i18nBundle.getText(SELECT_ROLE_DESCRIPTION);
}

get _isPhone() {
return isPhone();
}
Expand Down
3 changes: 3 additions & 0 deletions packages/main/src/i18n/messagebundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ FILEUPLOADER_TITLE=Upload File

GROUP_HEADER_TEXT=Group Header

#XACT: ARIA announcement for the Select`s roledescription attribute
SELECT_ROLE_DESCRIPTION=Select ComboBox

#XTXT: MultiComboBox and ComboBox icon accessible name
SELECT_OPTIONS=Select Options

Expand Down
6 changes: 5 additions & 1 deletion packages/main/test/specs/Select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,12 @@ describe("Select general interaction", () => {
assert.include(selectTextHtml, EXPECTED_SELECTION_TEXT2, "Select label is correct.");
});

it("Tests aria-label, aria-labelledby and aria-expanded", async () => {
it("Tests accessibility", async () => {
const select1 = await browser.$("#textAreaAriaLabel").shadow$(".ui5-select-label-root");
const select2 = await browser.$("#textAreaAriaLabelledBy").shadow$(".ui5-select-label-root");
const EXPECTED_ARIA_LABEL1 = "Hello World";
const EXPECTED_ARIA_LABEL2 = "info text";
const EXPECTER_ARIA_ROLEDESCRIPTION = "Select ComboBox";

assert.strictEqual(await select1.getAttribute("aria-label"), EXPECTED_ARIA_LABEL1,
"The aria-label is correctly set internally.");
Expand All @@ -415,5 +416,8 @@ describe("Select general interaction", () => {
"The aria-label is correctly set internally.");
assert.strictEqual(await select2.getAttribute("aria-expanded"), "false",
"The aria-expanded is false by default.");

assert.strictEqual(await select2.getAttribute("aria-roledescription"), EXPECTER_ARIA_ROLEDESCRIPTION,
"The aria-roledescription is correct.");
});
});

0 comments on commit e4fa811

Please sign in to comment.