question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Notification component's role="alert" creates accessibility issue for screen reader users

See original GitHub issue

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  1. Open example.
  2. Click button to open notification box.

What is actually happening?

Since role="alert" is used, the notification interrupt whatever the user is doing. This also stops a screen reader from finishing whatever it was saying before the alert interrupted it (and will not pick up where it left off) which can make a user feel stranded. Toast-style notifications should be used for non-critical, non-interactive content so it’s inappropriate to use role="alert" which implicitly has an aria-live value of assertive.

What is expected?

Instead, role="status" is more appropriate as it allows for current screen reader announcements to be read before announcing the non-critical notification content. This requires the notification elements to be with an element with role="region" and aria-live="polite".

Environment Info
antd 4.24.5
React React
System Windows 10
Browser All

More information:

Issue Analytics

  • State:open
  • Created 9 months ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Thulofcommented, Dec 16, 2022

Hi, @mellis481 @dgreene1 @MadCcc I have pushed a PR to add a role prop to notification component, please review it. https://github.com/ant-design/ant-design/pull/39611

0reactions
mellis481commented, Dec 15, 2022

Cannot find anything different, could you provide more detail for role="alert"?

@MadCcc The difference is succinctly described in the “What is actually happening?” and “What is expected?” sections above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ARIA: alert role - Accessibility - MDN Web Docs - Mozilla
The alert role is used to communicate an important and usually time-sensitive message to the user. When this role is added to an...
Read more >
Accessibility - Notification - Carbon Design System
The role of status , log , and alert can not contain interactive elements, should not be given focus, and can optionally be...
Read more >
Noticing screen readers using alert role - ADG
Setting role="alert" to a newly added DOM element (using JavaScript) forces the screen reader to announce its content, regardless of what it is...
Read more >
Provide notification of dynamic changes to content
Listen to the page with a screen reader. Are notifications made in an accessible way, including making users aware of important changes in...
Read more >
HTML5 Accessibility Chops: ARIA role=alert browser support
When an element has a role=alert is displayed it triggers an alert event in the browsers implemented accessibility APIs. This is picked up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found