Skip to content

Commit

Permalink
fix(ui5-button): adjust screen reader announcement order (SAP#8997)
Browse files Browse the repository at this point in the history
Fixes: SAP#8976
  • Loading branch information
unazko committed Jun 5, 2024
1 parent f899378 commit 0cd7335
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="{{buttonAccessibleRole}}"
Expand All @@ -39,7 +40,7 @@
</span>

{{#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 @@ -518,6 +518,10 @@ class Button extends UI5Element implements IFormElement, IButton {
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 @@ -118,6 +118,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 0cd7335

Please sign in to comment.