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 screen readers announcing toasts #1551

Merged
merged 1 commit into from
Jan 14, 2025
Merged

Conversation

nicooprat
Copy link
Contributor

I'm currently fixing accessibility for our app and migrating to Radix. I struggled to make screen readers announce toasts and I think I found the culprit.

aria-atomic attribute specifically needs the true value to be read by screen readers, and VoiceOver requires the role to be set as alert for some reason.

Also, announceTextContent seems to display content as an array which is weird when it's announced:

VoiceOver:
VoiceOver

NVDA:

NVDA

It's done on purpose (cf. https://github.com/unovue/radix-vue/blob/main/packages/radix-vue/src/Toast/utils.ts#L77-L78) but VoiceOver actually reads "3" as three inches for instance, because in our case we have a strong element on the number but there's no reason to make a pause between those words.

Setup:

  • NVDA + Firefox + Windows
  • VoiceOver + Safari + MacOS

Also I couldn't make screen readers read the label prop from the ToastViewport component, I'm not sure if it's expected.

In conclusion the proposed fix makes the component work at least in my tests, even if there's still room for improvement IMO.

Let me know what you think!

aria-atomic attribute specifically needs the "true" value to be read by screen readers, and VoiceOver requires the role "alert" for some reason
Copy link
Member

@zernonia zernonia left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @nicooprat ! Tested locally and it seems good! Yeah announceTextContent was designed to be an array.

The aria-label for ToastViewport will be focused and announced when we use the hotkey (default F8) to navigate to the region

@zernonia zernonia merged commit 6c49099 into unovue:main Jan 14, 2025
3 checks passed
Copy link

pkg-pr-new bot commented Jan 14, 2025

Open in Stackblitz

npm i https://pkg.pr.new/radix-vue@1551

commit: 6f91b26

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.

2 participants