ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug(a11y): assertive toast not announced

Open DavideMininni-Fincons opened this issue 2 years ago • 2 comments

Prerequisites

Ionic Framework Version

  • [ ] v4.x
  • [ ] v5.x
  • [X] v6.x
  • [ ] Nightly

Current Behavior

The toast message in not announced by screenreaders even with aria-live='assertive'.

Tested with:

  • Ionic 6.2.4
  • NVDA 2022.2.2 on Chrome and Firefox
  • JAWS 2022.2207.25 ILM on Chrome and Firefox

Expected Behavior

According to ARIA live regions spec:

aria-live="assertive" should only be used for time-sensitive/critical notifications that absolutely require the user's immediate attention. Generally, a change to an assertive live region will interrupt any announcement a screen reader is currently making. As such, it can be extremely annoying and disruptive and should only be used sparingly.

So I expect assertive toast message to be announced when toast is shown.

Steps to Reproduce

  • Checkout v.6.2.4
  • npm install in ./core
  • npm start
  • go to http://localhost:3333/src/components/toast/test/a11y using Chrome/Firefox
  • launch NVDA/JAWS
  • click on 'Present Assertive Toast'
  • no announcement

I could provide a demo app using @ionic/angular, but I need to test the toast behaviour with JAWS (with NVDA on Chrome/Firefox is not working).

Code Reproduction URL

No response

Ionic Info

[WARN] You are not in an Ionic project directory. Project context may be missing.

Ionic:

Ionic CLI : 5.4.16

Utility:

cordova-res : not installed native-run : not installed

System:

NodeJS : v14.17.1
npm : 6.14.13
OS : Linux 4.4

Additional Information

No response

DavideMininni-Fincons avatar Aug 31 '22 15:08 DavideMininni-Fincons

Thanks for the report. So there is an issue here, but it is unrelated to aria-live. Live regions control updates to content. From MDN Live Regions:

aria-live: The aria-live=POLITENESS_SETTING is used to set the priority with which screen reader should treat updates to live regions - the possible settings are: off, polite or assertive. The default setting is off. This attribute is by far the most important.

This means that if you were to update the message a few seconds after the toast was shown, narrators would announce the updated content according to your aria-live preference.


However, the issue here is that narrators do not announce toasts when they first appear. This is a bit tricky because a) toasts never receive focus and b) the intent of toasts may differ between use cases.

For toasts that require the user's immediate attention, role="alert" may be appropriate here. This will cause narrators to announce the toasts when they first appear. It also assumes aria-live="assertive" and aria-atomic="true", so narrators will be interrupted and announce the entire toast.

For toasts that do not require the user's immediate attention, role="status" may be appropriate here. This role assumes aria-live="polite" and aria-atomic="true". However, NVDA does not announce the toast when the toast is initially presented. It seems that the intent is role="status" regions are always present in the DOM.


When adding support for https://github.com/ionic-team/ionic-framework/issues/24484, this issue may go away since the overlay element will exist in the DOM ahead of time. However, we should investigate ways of solving this when using controller toasts too.

liamdebeasi avatar Aug 31 '22 20:08 liamdebeasi

Hi @liamdebeasi, and thank you for your quick answer 🚀

If it could help, I created this repo using the toast controller in an Angular project; from what I could see, the two toasts triggered during onInit are announced only by JAWS on Firefox (maybe confirming what you said about first apparition?). Toasts spawn by buttons click behave randomly - NVDA on Firefox never announce them, NVDA on Chrome and JAWS does it many times but not always.

Probably I could confirm what you said about #24484: in a pure JS environment, if I generate a div with aria-live attribute set, append it to body and then append the toast inside it, message is always announced.

DavideMininni-Fincons avatar Sep 01 '22 09:09 DavideMininni-Fincons

Thanks for the report. I was able to fix the NVDA announcement issue in https://github.com/ionic-team/ionic-framework/pull/27198. I did more research into how toasts should be used as part of this work. I discovered that toasts should only use polite presentation (Material Design spec for reference: https://m2.material.io/components/snackbars/web#accessibility). As a result, I also have a PR to update the docs that notes this: https://github.com/ionic-team/ionic-docs/pull/2914.

This fix should be available in an upcoming release of Ionic. Let me know if you have questions.

liamdebeasi avatar Apr 18 '23 15:04 liamdebeasi

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar May 18 '23 15:05 ionitron-bot[bot]