Skip to content

Commit

Permalink
fix(ui5-button): adjust screen reader announcement order (#8997)
Browse files Browse the repository at this point in the history
Fixes: #8976
  • Loading branch information
unazko committed Jun 5, 2024
1 parent b8d7bac commit 2d9a16b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/main/src/Button.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
aria-controls="{{accessibilityAttributes.controls}}"
aria-haspopup="{{_hasPopup}}"
aria-label="{{ariaLabelText}}"
aria-describedby="{{ariaDescribedbyText}}"
title="{{buttonTitle}}"
part="button"
role="{{effectiveAccRole}}"
Expand Down Expand Up @@ -48,7 +49,7 @@
{{/if}}

{{#if hasButtonType}}
<span class="ui5-hidden-text">{{buttonTypeText}}</span>
<span id="ui5-button-hiddenText-type" aria-hidden="true" class="ui5-hidden-text">{{buttonTypeText}}</span>
{{/if}}
</button>

Expand Down
4 changes: 4 additions & 0 deletions packages/main/src/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,10 @@ class Button extends UI5Element implements IButton, IFormElement {
return getEffectiveAriaLabelText(this);
}

get ariaDescribedbyText() {
return this.hasButtonType ? "ui5-button-hiddenText-type" : undefined;
}

get _isSubmit() {
return this.type === ButtonType.Submit || this.submits;
}
Expand Down
8 changes: 8 additions & 0 deletions packages/main/test/specs/Button.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ describe("Button general interaction", () => {
assert.strictEqual(await innerButton.getAttribute("aria-controls"), "registration-dialog", "Attribute is reflected");
});

it("aria-describedby properly applied on the button tag", async () => {
const button = await browser.$("#button-with-slot");
const innerButton = await button.shadow$("button");
const invisibleButtonType = await innerButton.$$("span")[1];

assert.strictEqual(await innerButton.getAttribute("aria-describedby"), await invisibleButtonType.getAttribute("id"), "Attribute is reflected");
});

it("tests button with text icon role", async () => {
const button = await browser.$("#attentionIconButton");
const icon = await button.shadow$("ui5-icon");
Expand Down

0 comments on commit 2d9a16b

Please sign in to comment.