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(overlay): hide from screen readers while animating #29951

Merged
merged 27 commits into from
Oct 24, 2024
Merged

fix(overlay): hide from screen readers while animating #29951

merged 27 commits into from
Oct 24, 2024

Conversation

thetaPC
Copy link
Contributor

@thetaPC thetaPC commented Oct 18, 2024

Issue number: resolves #29857


What is the current behavior?

Screen readers like Android Talkback would not have the focus ring on the correct element. For example, Talkback would announce the buttons correctly within action sheet but the focus ring was no where to be seen.

After digging around, the focus rings are located out of screen because the action sheet is mounted to the DOM out of the screen first then transitions into the screen. There are some screen readers that do not behave as expected when an element uses transform styles like action sheet.

ion-select-missing-focus.mp4

What is the new behavior?

  • When an overlay is being animated (presenting or dismissing), the overlay will hide from screen readers. This allows the element to navigate to its correct destination for screen readers to interact with. Plus, we shouldn't allow screen readers to interact with content in the middle of an animation. It could lead to some confusion.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev build: 8.3.3-dev.11729276019.194c165c

A physical Android device will be needed, the issue does not appear in simulators

Components that need to be tested because they use overlays:

  • Action sheet
  • Alert
  • Loading
  • Modal
  • Popover
  • Select w/ action sheet interface
  • Select w/ alert interface
  • Select w/ popover interface
  • Toast

How to test:

  1. Create a starter app (any framework will do)
  2. Add an action sheet
  3. Build app for mobile devices
ionic build

ionic cap add ios
ionic cap add android

ionic cap copy && ionic cap sync
  1. Open the app in Android Studio: ionic cap open android
  2. Connect the Android device to Android Studio
  3. Open app in Android device
  4. Launch Talkback
  5. Navigate back to the app
  6. Open action sheet
  7. Swipe over to the action sheet's buttons
  8. Notice that the buttons don't have a focus ring
  9. Go back to the starter
  10. Install the dev build
  11. Add the components to the app
  12. Sync app: ionic cap copy && ionic cap sync
  13. Relaunch the app on the Android device
  14. Verify that the focus ring appears on the action sheet's buttons
  15. Verify that the other overlays are working as intended

Copy link

vercel bot commented Oct 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 23, 2024 5:33pm

@github-actions github-actions bot added the package: core @ionic/core package label Oct 18, 2024
@@ -514,7 +514,8 @@ export const present = async <OverlayPresentOptions>(

document.body.classList.add(BACKDROP_NO_SCROLL);

hideOverlaysFromScreenReaders(overlay.el);
hideUnderlyingOverlaysFromScreenReaders(overlay.el);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just changed the name to distinguish between this function and the next.

@thetaPC thetaPC marked this pull request as ready for review October 18, 2024 19:13
@thetaPC thetaPC requested a review from a team as a code owner October 18, 2024 19:13
@Ornel21

This comment was marked as duplicate.

const hideAnimatingOverlayFromScreenReaders = (overlay: HTMLIonOverlayElement) => {
if (doc === undefined) return;

overlay.setAttribute('aria-hidden', 'true');
Copy link
Member

Choose a reason for hiding this comment

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

Optional: maybe add a comment referencing where the attribute is being added. My initial thought was: when we set it here, will it ever be removed somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@thetaPC thetaPC added this pull request to the merge queue Oct 24, 2024
Merged via the queue into main with commit cb60073 Oct 24, 2024
48 checks passed
@thetaPC thetaPC deleted the ROU-11242 branch October 24, 2024 15:46
github-merge-queue bot pushed a commit that referenced this pull request Nov 22, 2024
Issue number: internal

---------

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

PR #29951 would hide
the overlays from screen readers while animating. This allows the
element to navigate to its correct destination for screen readers to
interact with. Otherwise, the focus rings would never appear. However,
this ended up breaking the interaction for iOS.

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

- Overlays are hidden from screen readers while animating only if the
platform is `android`. Since the original issue only applied to Android
devices.

## 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/docs/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: `8.4.1-dev.11732033492.170e160c`

Test on iOS and Android devices.
github-merge-queue bot pushed a commit that referenced this pull request Nov 27, 2024
Issue number: internal

---------

<!-- 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 the menu is presented on an Android device, TalkBack's focus rings
may appear in the wrong position due to the transition (specifically
`transform` styles). This occurs because the focus rings are initially
displayed at the starting position of the elements before the transition
begins.

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

- When an overlay is being animated (presenting or dismissing), the
overlay will hide from screen readers. This allows Talkback to display
the focus rings on the correct position.

## 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/docs/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: `8.4.1-dev.11732305980.19d90e1c`

Related to #29951
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: Focus state at ion-select with interface of action-sheet using TalkBack
3 participants