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

fix(toast): adding alert role for toast #492

Merged
merged 6 commits into from
Aug 30, 2022
Merged

Conversation

ChronosSF
Copy link
Member

@ChronosSF ChronosSF commented Aug 25, 2022

Closes #479

@ChronosSF ChronosSF added a11y When the issue or PR is related to accessibility ❌ status: awaiting-test toast labels Aug 25, 2022
@ChronosSF ChronosSF marked this pull request as ready for review August 25, 2022 13:42
@ChronosSF
Copy link
Member Author

@rkaraivanov , @desig9stein , So I played with this some more based on this document: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role

  • Without role: alert the message is not read
  • With role: alert NVDA reads it perfectly on show. As the docs state, changing the display property of a role: alert element is supposed to trigger a read from assistive software and that seems to be the case with nvda
  • With the Windows Narrator, this works half of the time (basically each other toggle). I also tried using the "JS method" as described in the document (basically adding the role attribute on show and removing it on hide) but it didn't produce better results in Windows Narrator

@desig9stein could you please test role: alert on a Mac and see if it works?

Comment on lines 39 to 44
constructor() {
super();
if (!this.hasAttribute('role')) {
this.setAttribute('role', 'alert');
}
}
Copy link
Member

Choose a reason for hiding this comment

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

You should move this to the connectedCallback hook.
As per the specification:

The element must not gain any attributes or children, as this violates the expectations of consumers who use the createElement or createElementNS methods.

@desig9stein
Copy link
Contributor

@ChronosSF The reader on mac does not read anything with just the role, however, adding aria-live="polite" seems to fix the problem.

We use the same approach in Angular.

igx toast
aria-live

@ChronosSF
Copy link
Member Author

Sadly, providing any aria-live seems to completely kill off the read out from Windows Narrator, but that seems to be the case with angular too. I guess having it read on Mac is better as we kinda go in the way of using nvda as baseline.

@rkaraivanov rkaraivanov merged commit 9567665 into master Aug 30, 2022
@rkaraivanov rkaraivanov deleted the sstoychev/toast-accs branch August 30, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y When the issue or PR is related to accessibility toast ✅ status: verified
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Toast accessibility improvements
3 participants