Skip to content

fix(ui5-button): announce accessible name #11396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

unazko
Copy link
Contributor

@unazko unazko commented Apr 23, 2025

Issue:

  • The badge wasn't announced at all when an accessible-name attribute is provided
    for the ui5-button. The reason behind this behaviour is that the screen reader doesn't
    read the inner text nodes of the root button node when the same has aria-label attribute.

Solution:

  • The proper badge description text is placed into the aria-label attribute of the root
    button element. As a result the screen reader won't rely on the inner text content
    for the announcements.
  • Additionally the design description is also moved into the aria-label attribute,
    in order to keep a proper announcement order.

Fixes: #11350

@unazko unazko marked this pull request as ready for review April 23, 2025 14:49
@unazko unazko requested review from hinzzx and Copilot April 25, 2025 07:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an accessibility issue for the ui5-button by updating how the accessible name and badge description are announced. Key changes include:

  • Updating the aria-label generation by combining the accessible name, button type, and badge description.
  • Adjusting the aria-description handling to return undefined when empty.
  • Modifying the Cypress tests to validate the updated accessibility attributes.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/main/src/Button.ts Updates aria-label and badge description generation for improved announcement.
packages/main/cypress/specs/Button.cy.tsx Updates tests to reflect new accessibility attribute behaviors.
Files not reviewed (1)
  • packages/main/src/i18n/messagebundle.properties: Language not supported
Comments suppressed due to low confidence (1)

packages/main/cypress/specs/Button.cy.tsx:332

  • Consider adding additional tests for edge cases such as badge values like "0" or unexpected non-numeric texts to ensure that the aria-label formation handles all scenarios robustly.
.should("have.attr", "aria-label", `Download 999+ items`);

@unazko unazko requested a review from tsanislavgatev May 8, 2025 07:31
@unazko unazko self-assigned this May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ui5-button]: Badge content is ignored when accessible-name is used
2 participants