Skip to content

bug(a11y): assertive toast not announced #25866

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

Closed
4 of 7 tasks
DavideMininni-Fincons opened this issue Aug 31, 2022 · 4 comments · Fixed by #27198
Closed
4 of 7 tasks

bug(a11y): assertive toast not announced #25866

DavideMininni-Fincons opened this issue Aug 31, 2022 · 4 comments · Fixed by #27198
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@DavideMininni-Fincons
Copy link

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.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

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

@liamdebeasi
Copy link
Contributor

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 #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.

@DavideMininni-Fincons
Copy link
Author

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.

@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report labels Nov 3, 2022
@ionitron-bot ionitron-bot bot removed the triage label Nov 3, 2022
@liamdebeasi
Copy link
Contributor

Thanks for the report. I was able to fix the NVDA announcement issue in #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: ionic-team/ionic-docs#2914.

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

liamdebeasi added a commit that referenced this issue Apr 18, 2023
Issue URL: resolves #25866

---------

Docs PR: ionic-team/ionic-docs#2914

<!-- Please refer to our contributing documentation for any questions on
submitting a pull request, or let us know here if you need any help:
https://ionicframework.com/docs/building/contributing -->

<!-- Some docs updates need to be made in the `ionic-docs` repo, in a
separate PR. See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation
for details. -->

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->


<!-- Issues are required for both bug fixes and features. -->

NVDA is not announcing toasts on present.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Toast has a "status" role and "polite" announcement.
- We also revisited the intended behavior of toasts to better align with
the Material Design v2 spec:
https://m2.material.io/components/snackbars/web#accessibility

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

Dev build: 7.0.3-dev.11681482468.19d7784f
@liamdebeasi liamdebeasi removed their assignment Apr 18, 2023
liamdebeasi added a commit that referenced this issue Apr 19, 2023
Issue URL: resolves #25866

---------

Docs PR: ionic-team/ionic-docs#2914

<!-- Please refer to our contributing documentation for any questions on
submitting a pull request, or let us know here if you need any help:
https://ionicframework.com/docs/building/contributing -->

<!-- Some docs updates need to be made in the `ionic-docs` repo, in a
separate PR. See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation
for details. -->

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->


<!-- Issues are required for both bug fixes and features. -->

NVDA is not announcing toasts on present.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Toast has a "status" role and "polite" announcement.
- We also revisited the intended behavior of toasts to better align with
the Material Design v2 spec:
https://m2.material.io/components/snackbars/web#accessibility

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

Dev build: 7.0.3-dev.11681482468.19d7784f
@ionitron-bot
Copy link

ionitron-bot bot commented May 18, 2023

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 ionitron-bot bot locked and limited conversation to collaborators May 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants