Skip to content
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

feat(badge): a badge with some meaningful information should not have the aria-hidden=true attribute #26190

Closed
GregoireLgt opened this issue Dec 6, 2022 · 8 comments · Fixed by #27025
Labels
Accessibility This issue is related to accessibility (a11y) area: material/badge feature This issue represents a new feature or feature request rather than a bug or bug fix P2 The issue is important to a large percentage of users, with a workaround

Comments

@GregoireLgt
Copy link

GregoireLgt commented Dec 6, 2022

Feature Description

For accessibility purposes,

When you have a badge which communicates some meaningful information such as a number or something else, it should not have the aria-hidden=true attribute

So is it possible to create in the API a new "matBadgeAriaHidden" directive to set it manually according to the relevance of the badge content?

Use Case

No response

@GregoireLgt GregoireLgt added feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team labels Dec 6, 2022
@zarend
Copy link
Contributor

zarend commented Dec 12, 2022

Hello @GregoireLgt,

The badge has an matBadgeDescription Input, which provides an aria-description. Does that work for your use case?

-Zach

@zarend zarend added Accessibility This issue is related to accessibility (a11y) P4 A relatively minor issue that is not relevant to core functions needs: clarification The issue does not contain enough information for the team to determine if it is a real bug area: material/badge and removed needs triage This issue needs to be triaged by the team labels Dec 12, 2022
@GregoireLgt
Copy link
Author

GregoireLgt commented Dec 14, 2022

Hi @zarend,

I think this should do the trick.

However it's still weird that the aria-hidden attribute is set at true and can't be changed as you can see below (from the first example at https://v14.material.angular.io/components/badge/overview)

image

Corresponding badge code with aria-hidden true :

image

That makes the content of the badge unreadable by assistive technologies since aria-hidden is true.

As stated on MDN :
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden
image

So the solution is using an aria-describedby attribute to describe the content of the badge via the matBadgeDescription input if i am correct?

In the example, the badge is communicating meaningful info (a number which could be anything depending on the context of your app), so i was wondering if just setting aria-hidden to false is more clean maybe in terms of accessibility?

Regards

@GregoireLgt
Copy link
Author

@zarend i tried the matBadgeDescription input but i was not able to make my assistive technology read the matBadgeDescription. I also tried adding another element with the sr-only class in order to describe what's inside the badge but it was the same. That would be really helpful to change the aria-hidden attribute.

Regards

@zarend
Copy link
Contributor

zarend commented Jan 23, 2023

Hello @GregoireLgt ,

Thank you for following up with this. Which assistive technology are you using?

-Zach

@GregoireLgt
Copy link
Author

@zarend i use NVDA : https://www.nvaccess.org/download/

Regards,
-Gregoire

@epstarr
Copy link

epstarr commented Jan 25, 2023

Commenting here after finding this thread through Google. Our company's application was flagged for this same error while using a matBadge during an accessibility audit. Our implementation is to show the user how many errors exist on a form. Seeing how this would be deemed important information for the user to gather through a screenreader, we'd have to drop our usage of the badge until this (hopefully) gets addressed

@zarend
Copy link
Contributor

zarend commented Jan 30, 2023

Hello folks,

The matBadgeDescription is working better right now on interactive elements rather than static content. I believe the intention is that the matBadgeDescription is supposed to be read for both static and interactive elements, and developers shouldn't need to change the aria-hidden.

Here's a few work-arounds to try:

  • Change the element that hosts the matBadgeDescription to a <button/> or some other interactive element
  • Add content inside the badge with cdk-visually-hidden class to announce description
  <span matBadge="4" matBadgeOverlap="false" class="demo-section">
   Text with a badge
   <span class="cdk-visually-hidden">4 notifications</span>
 </span>

Hope that helps in the meantime before this gets addressed.

-Zach

@zarend zarend added P2 The issue is important to a large percentage of users, with a workaround and removed P4 A relatively minor issue that is not relevant to core functions needs: clarification The issue does not contain enough information for the team to determine if it is a real bug labels Feb 13, 2023
jelbourn added a commit to jelbourn/components that referenced this issue May 3, 2023
The badge current applies `aria-describedby` to surface the
developer-provided description. However, assistive technology generally
doesn't read these description on non-interactive elements. So, we can
take advantage of our handy `InteractivityChecker` and do something
different if the host is not focusable; we add the description inline as
the next sibling with `.cdk-visually-hidden`.

Fixes angular#26190
jelbourn added a commit to jelbourn/components that referenced this issue May 3, 2023
The badge current applies `aria-describedby` to surface the
developer-provided description. However, assistive technology generally
doesn't read these description on non-interactive elements. So, we can
take advantage of our handy `InteractivityChecker` and do something
different if the host is not focusable; we add the description inline as
the next sibling with `.cdk-visually-hidden`.

Fixes angular#26190
jelbourn added a commit to jelbourn/components that referenced this issue May 3, 2023
The badge current applies `aria-describedby` to surface the
developer-provided description. However, assistive technology generally
doesn't read these description on non-interactive elements. So, we can
take advantage of our handy `InteractivityChecker` and do something
different if the host is not focusable; we add the description inline as
the next sibling with `.cdk-visually-hidden`.

Fixes angular#26190
jelbourn added a commit to jelbourn/components that referenced this issue May 4, 2023
The badge current applies `aria-describedby` to surface the
developer-provided description. However, assistive technology generally
doesn't read these description on non-interactive elements. So, we can
take advantage of our handy `InteractivityChecker` and do something
different if the host is not focusable; we add the description inline as
the next sibling with `.cdk-visually-hidden`.

Fixes angular#26190
jelbourn added a commit to jelbourn/components that referenced this issue May 5, 2023
The badge current applies `aria-describedby` to surface the
developer-provided description. However, assistive technology generally
doesn't read these description on non-interactive elements. So, we can
take advantage of our handy `InteractivityChecker` and do something
different if the host is not focusable; we add the description inline as
the next sibling with `.cdk-visually-hidden`.

Fixes angular#26190
jelbourn added a commit to jelbourn/components that referenced this issue May 5, 2023
The badge current applies `aria-describedby` to surface the
developer-provided description. However, assistive technology generally
doesn't read these description on non-interactive elements. So, we can
take advantage of our handy `InteractivityChecker` and do something
different if the host is not focusable; we add the description inline as
the next sibling with `.cdk-visually-hidden`.

Fixes angular#26190
angular-robot bot pushed a commit that referenced this issue May 9, 2023
…sts (#27025)

The badge current applies `aria-describedby` to surface the
developer-provided description. However, assistive technology generally
doesn't read these description on non-interactive elements. So, we can
take advantage of our handy `InteractivityChecker` and do something
different if the host is not focusable; we add the description inline as
the next sibling with `.cdk-visually-hidden`.

Fixes #26190
angular-robot bot pushed a commit that referenced this issue May 9, 2023
…sts (#27025)

The badge current applies `aria-describedby` to surface the
developer-provided description. However, assistive technology generally
doesn't read these description on non-interactive elements. So, we can
take advantage of our handy `InteractivityChecker` and do something
different if the host is not focusable; we add the description inline as
the next sibling with `.cdk-visually-hidden`.

Fixes #26190

(cherry picked from commit f0a5008)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) area: material/badge feature This issue represents a new feature or feature request rather than a bug or bug fix P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants