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(overlays): ensure that only topmost overlay is announced by screen readers #28997

Merged
merged 18 commits into from Feb 9, 2024

Conversation

amandaejohnston
Copy link
Contributor

@amandaejohnston amandaejohnston commented Feb 7, 2024

Issue number: resolves #23472


What is the current behavior?

If multiple overlays are presented at the same time, none of them receive aria-hidden="true". This means that screen readers can read contents from overlays behind the current one, which can be confusing for users.

The original issue also reports router outlets getting aria-hidden removed when any overlay is dismissed, not just the last one, but we've since fixed that:

* If this is the last visible overlay then
* we want to re-add the root to the accessibility tree.
*/
if (doc !== undefined && getPresentedOverlays(doc).length === 1) {

What is the new behavior?

All overlays besides the topmost one now receive aria-hidden="true". This means that screen readers will only announce the topmost overlay.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@github-actions github-actions bot added the package: core @ionic/core package label Feb 7, 2024
@@ -62,7 +62,7 @@
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
Modal Content
Modal ${id}
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 isn't necessary for the fix, but I found it very useful while debugging since the page lets you create as many modals as you want, and this makes it easier to tell which one you're looking at. I can revert if we'd rather keep things slim.

@amandaejohnston amandaejohnston marked this pull request as ready for review February 8, 2024 16:55
@amandaejohnston amandaejohnston requested a review from a team as a code owner February 8, 2024 16:55
@amandaejohnston amandaejohnston requested review from brandyscarney and removed request for a team February 8, 2024 16:55
@amandaejohnston
Copy link
Contributor Author

We might have a better fix for the spec test issue. Moving to draft for a sec.

@amandaejohnston amandaejohnston marked this pull request as draft February 8, 2024 18:10
@amandaejohnston amandaejohnston marked this pull request as ready for review February 8, 2024 19:23
@amandaejohnston
Copy link
Contributor Author

Okay, all good now 👍

Copy link
Contributor

@sean-perkins sean-perkins left a comment

Choose a reason for hiding this comment

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

Tested the changes locally with voice over, works great!

Can we update the PR description to describe the new behavior impact? For example:

Screen readers will announce only the top-most visible overlay.

Suggestion for the PR title, can we use "announced" language vs. visible?

@amandaejohnston amandaejohnston changed the title fix(overlays): ensure that only topmost overlay is visible to screen readers fix(overlays): ensure that only topmost overlay is announced by screen readers Feb 9, 2024
@amandaejohnston amandaejohnston added this pull request to the merge queue Feb 9, 2024
Merged via the queue into main with commit ba4ba61 Feb 9, 2024
46 checks passed
@amandaejohnston amandaejohnston deleted the FW-4929 branch February 9, 2024 15:54
github-merge-queue bot pushed a commit that referenced this pull request Mar 12, 2024
Issue number: resolves #29139 

---------

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

When implementing
#28997 we did not
consider the case where a Toast could be presented. When presenting a
Toast after presenting a Modal the linked change causes the Modal to be
hidden from screen readers.

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

- If the top-most overlay is a Toast then the closest non-Toast overlay
is also not hidden from screen readers.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer
for more information.
-->


## 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.7.5-dev.11710260658.1fc29a6c`

---------

Co-authored-by: Amanda Johnston <90629384+amandaejohnston@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Screen readers read content behind overlays if is present more than 1 overlay
2 participants