Skip to content

Conversation

@ze-flo
Copy link
Contributor

@ze-flo ze-flo commented Apr 17, 2024

Description

  • Sets Nofitication's role to alert to improve compatibility with JAWS, Narrator, and NVDA.
  • Set aria-hidden to Notification's Close button to improve UX.

Detail

I've tested the following combinations using the latest version of the browser and screen-reader:

  • Chrome + JAWS
  • Chrome + NVDA
  • Edge + Narrator
  • Chrome + Narrator
  • Chrome + VoiceOver
  • Safari + VoiceOver

Screen Shot 2024-04-17 at 12 19 49 PM

Two methods were compared:

  1. "Incremental notifications": This is current pattern where a role of status or alert is applied to Notification. When the Notification incrementally mounts, the SR will read out loud its content.
  2. "Persistent aria-live region": This region has an aria-live attribute set to either polite or assertive and is mounted by the ToastProvider on load. Changes to its content will be announced incrementally by setting the attribute aria-atomic to false.

Conclusion

There is no perfect solution but role="alert" on Notification seems best.

TL;DR

The "Persistent aria-live region" offers wider SR compatibility with with aria-live=polite but completely fails with Chrome + Narrator. Additionally, the assertive behavior of JAWS and NVDA remains polite regardless of aria-live setting.

Setting role="alert" on Notification provides more consistent results. Most SR's except Narrator would announce the notification with an alert prefix or a chime (VoiceOver) before reading its content. That helps users better distinguish such events but at the cost of the occasional announcement interruption.

Checklist

  • 👌 design updates will be Garden Designer approved (add the designer as a reviewer)
  • 🌐 demo is up-to-date (npm start)
  • ⬅️ renders as expected with reversed (RTL) direction
  • 🤘 renders as expected with Bedrock CSS (?bedrock)
  • 💂‍♂️ includes new unit tests. Maintain existing coverage (always >= 96%)
  • ♿ tested for WCAG 2.1 AA accessibility compliance
  • 📝 tested in Chrome, Firefox, Safari, and Edge


return (
<StyledClose ref={ref} hue={hue} aria-label={ariaLabel} {...props}>
<StyledClose ref={ref} hue={hue} aria-label={ariaLabel} {...props} aria-hidden>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a controversial quality-of-life enhancement. With the assumption that most notifications are auto-dismissed and because we are against focus stealing, it's unlikely screen-reader users will be able to use the Close button. Therefore, I think it's better to remove it from the a11y tree to prevent its announcement.

Additionally, I could first check that the autoDismiss is true before applying aria-hidden.

Thoughts? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't feel right to me. Garden's approach to accessibility is a pragmatic one. If a close exists, there shouldn't be harm in announcing it. I'm also not aware of this being flagged during a11y audit – so best not to touch it.

Copy link
Contributor

@geotrev geotrev Apr 17, 2024

Choose a reason for hiding this comment

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

My only concern is your wording: "most notifications" - implying there are some notifications that may still receive focus, right?

EDIT: oop JZ commented before me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I'll revert.

@ze-flo ze-flo marked this pull request as ready for review April 17, 2024 01:03
@ze-flo ze-flo requested a review from a team as a code owner April 17, 2024 01:03
Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

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

Narrator is not part of Garden's testing matrix. We follow Zendesk's recommended screen readers and browsers – which includes Safari + VO. What is the affect on that combo?

</StyledIcon>
)}
return (
<StyledNotification ref={ref} type={props.type} isFloating {...props} 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.

Please retain the existing role override so that consumers can continue to cater to their specific needs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my testing, any role other than alert will not trigger an announcement on JAWS or NVDA. Leaving it up to the user could create an opportunity for an A11Y bug. Can Notification be used outside of a "toast" pattern?

Copy link
Member

Choose a reason for hiding this comment

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

Can Notification be used outside of a "toast" pattern?

By definition, yes. Conversely, ToastProvider can receive other types of content. Let's stick with Garden's approach of a) doing the right thing, b) giving the user control over the corner cases.


return (
<StyledClose ref={ref} hue={hue} aria-label={ariaLabel} {...props}>
<StyledClose ref={ref} hue={hue} aria-label={ariaLabel} {...props} aria-hidden>
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't feel right to me. Garden's approach to accessibility is a pragmatic one. If a close exists, there shouldn't be harm in announcing it. I'm also not aware of this being flagged during a11y audit – so best not to touch it.

@ze-flo
Copy link
Contributor Author

ze-flo commented Apr 17, 2024

Narrator is not part of Garden's testing matrix. We follow Zendesk's recommended screen readers and browsers – which includes Safari + VO. What is the affect on that combo?

Thanks for the helpful link. I'll test that combo. 👍

Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

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

Approved, but left a minor cleanup that was present before this work.

</StyledIcon>
)}
return (
<StyledNotification ref={ref} type={props.type} isFloating role="alert" {...props}>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<StyledNotification ref={ref} type={props.type} isFloating role="alert" {...props}>
<StyledNotification ref={ref} type={type} isFloating role="alert" {...props}>

Not exactly related to this PR, but should type be structured out in the parameters above so that it doesn't (re)spread?

@ze-flo ze-flo merged commit 7643e4e into main Apr 18, 2024
@ze-flo ze-flo deleted the ze-flo/a11y-toast branch April 18, 2024 17:40
jzempel added a commit that referenced this pull request Apr 23, 2024
* fix(Notifications): improve screen-reader support (#1790)

* chore(changelog): add v8.76.1

---------

Co-authored-by: Florent <ze-flo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants