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): correctly re-add root to accessibility tree #28183

Merged
merged 5 commits into from
Sep 19, 2023
Merged

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Sep 15, 2023

Issue number: resolves #28180


What is the current behavior?

When presenting an overlay, we remove the root (usually ion-router-outlet) from the accessibility tree. This makes it so you cannot accidentally focus elements behind the overlay. When dismissing an overlay we re-add the root to the accessibility tree. However, we fail to consider if there are multiple presented overlays. For example, if you present a modal, then an alert, then dismiss the alert, then the root is re-added to the accessibility tree even though the modal is still presented.

What is the new behavior?

  • The root is now re-added to the accessibility tree only if it is the last presented overlay.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev build: 7.4.1-dev.11694783260.13da477f

@github-actions github-actions bot added the package: core @ionic/core package label Sep 15, 2023
@liamdebeasi liamdebeasi changed the title Fw 5167 fix(overlays): correctly re-add root to accessibility tree Sep 15, 2023
@liamdebeasi liamdebeasi marked this pull request as ready for review September 15, 2023 13:27
@liamdebeasi liamdebeasi requested review from a team and sean-perkins and removed request for a team September 15, 2023 13:27
const getPresentedOverlays = (doc: Document, overlayTag?: string): HTMLIonOverlayElement[] => {
return getOverlays(doc, overlayTag).filter((o) => !isOverlayHidden(o));
};

/**
* Returns an overlay element
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we either update the comment on this function to mention it returns a presented overlay element and/or refactor the function name to getPresentedOverlay?

I can see the current naming overlap being confusing:

  • getOverlays - returns visible/non-visible overlays
  • getPresentedOverlays - returns only visible overlays
  • getOverlay - returns only a visible overlay

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good thought. Clarified in 905bd86 and 3e7b65d

@liamdebeasi liamdebeasi added this pull request to the merge queue Sep 19, 2023
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.

Nice work!

Merged via the queue into main with commit 81714d4 Sep 19, 2023
@liamdebeasi liamdebeasi deleted the FW-5167 branch September 19, 2023 15:03
liamdebeasi added a commit that referenced this pull request Sep 22, 2023
Issue number: resolves #28180

---------

<!-- 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 presenting an overlay, we remove the root (usually
`ion-router-outlet`) from the accessibility tree. This makes it so you
cannot accidentally focus elements behind the overlay. When dismissing
an overlay we re-add the root to the accessibility tree. However, we
fail to consider if there are multiple presented overlays. For example,
if you present a modal, then an alert, then dismiss the alert, then the
root is re-added to the accessibility tree even though the modal is
still presented.

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

- The root is now re-added to the accessibility tree only if it is the
last presented overlay.

## 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.4.1-dev.11694783260.13da477f`
liamdebeasi added a commit that referenced this pull request Sep 26, 2023
Issue number: resolves #28180

---------

<!-- 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 presenting an overlay, we remove the root (usually
`ion-router-outlet`) from the accessibility tree. This makes it so you
cannot accidentally focus elements behind the overlay. When dismissing
an overlay we re-add the root to the accessibility tree. However, we
fail to consider if there are multiple presented overlays. For example,
if you present a modal, then an alert, then dismiss the alert, then the
root is re-added to the accessibility tree even though the modal is
still presented.

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

- The root is now re-added to the accessibility tree only if it is the
last presented overlay.

## 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.4.1-dev.11694783260.13da477f`
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: ion-router-outlet not marked aria-hidden when multiple overlays are presented and some dismissed
2 participants