-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: unintended re-focus to input after selecting clear input button with iOS VoiceOver #29358
bug: unintended re-focus to input after selecting clear input button with iOS VoiceOver #29358
Comments
Thanks for the report. Here is a dev build with a proposed fix if you are interested in testing: |
@liamdebeasi |
@liamdebeasi Thanks for considering this and for all the hard work you put into Ionic! |
Issue number: resolves #29358 --------- <!-- 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 clear button is focused, `focusin` is dispatched and bubbles up to the `ion-input`. Our [scroll assist utility listens for `focusin`](https://github.com/ionic-team/ionic-framework/blob/2fc81ddc9b35d6909fd4b585079aedabbd659233/core/src/utils/input-shims/hacks/scroll-assist.ts#L135) to adjust the scroll position. It also causes the input to be re-focused. As a result, when swiping to the clear button with a screen reader, focus will be forcibly moved back to the input. This means that users cannot swipe away from the input to the right when using a screen reader. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - To fix this, I decided to have the `focusin` event from the clear button not bubble (as opposed to add a really specific workaround to the scroll assist utility). Adding `stopPropagation` was easy enough, but it turned out that the scroll assist listeners were all configured to listen during the capture phase instead of the bubble phase. As a result, `stopPropgation` had no effect because the scroll assist callback had already fired. To address this, I updated the listeners to listen during the bubbling phase instead of the capture phase. Based on my testing the capture phase was not required for scroll assist to work, so it appears safe to remove. ## 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.0.1-dev.11713535425.1a4afba3` Reviewers: Please test this on a physical iOS device and be sure to test the scroll assist behavior. There is a test at http://localhost:3333/src/utils/input-shims/hacks/test you can use.
Thanks for the issue. This has been resolved via #29366, and a fix will be available in an upcoming release of Ionic Framework. We also plan to backport this to Ionic v7. |
Issue number: resolves #29358 --------- <!-- 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 clear button is focused, `focusin` is dispatched and bubbles up to the `ion-input`. Our [scroll assist utility listens for `focusin`](https://github.com/ionic-team/ionic-framework/blob/2fc81ddc9b35d6909fd4b585079aedabbd659233/core/src/utils/input-shims/hacks/scroll-assist.ts#L135) to adjust the scroll position. It also causes the input to be re-focused. As a result, when swiping to the clear button with a screen reader, focus will be forcibly moved back to the input. This means that users cannot swipe away from the input to the right when using a screen reader. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - To fix this, I decided to have the `focusin` event from the clear button not bubble (as opposed to add a really specific workaround to the scroll assist utility). Adding `stopPropagation` was easy enough, but it turned out that the scroll assist listeners were all configured to listen during the capture phase instead of the bubble phase. As a result, `stopPropgation` had no effect because the scroll assist callback had already fired. To address this, I updated the listeners to listen during the bubbling phase instead of the capture phase. Based on my testing the capture phase was not required for scroll assist to work, so it appears safe to remove. ## 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.0.1-dev.11713535425.1a4afba3` Reviewers: Please test this on a physical iOS device and be sure to test the scroll assist behavior. There is a test at http://localhost:3333/src/utils/input-shims/hacks/test you can use.
Thank you, it helps a lot! |
@liamdebeasi |
Hey there! I don't work for Ionic anymore, but you could bring it up with the team. I will note that the legacy input has been deprecated for over a year in v7, so I'm not sure what the team's appetite for backporting this fix to the legacy input will be. cc @brandyscarney |
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. |
Prerequisites
Ionic Framework Version
v7.x, v8.x (Beta)
Current Behavior
When using iOS VoiceOver to focus on an ion-input with a clear input button, and swiping right to select the next item, the focus unexpectedly returns to the
input
immediately after the clear input button gains focus. Consequently, it becomes impossible to move VoiceOver's focus away from theinput
, effectively preventing interaction with other parts of the app.I have attached a screen recording to demonstrate this behavior.
Expected Behavior
The VoiceOver focus should remain on the clear input button and not revert back to the input field after it has been selected.
Steps to Reproduce
focusin
events:ion-input
'sfocusin
event is triggered after thebutton
’s event.ion-input
(as demonstrated in the uploaded screen recording) and repeat the previous step.Code Reproduction URL
https://stackblitz.com/edit/usdwwp?file=index.html
Ionic Info
I use online StackBlitz to reproduce the issue using
@ionic/[email protected]
, but just in case information about my local environment is needed:Additional Information
Cause of the Behavior
The issue arises because iOS VoiceOver triggers a
focusin
event when selecting an element. This event bubbles up, causing thefocusin
event of theion-input
to be fired subsequent to the clear input button'sfocusin
event. Consequently, theinput
receives focus again as part of the callback function of theion-input
, which leads to the focus unexpectedly returning.Suggested Fix
The current implementation compares
document.activeElement
with the element to be focused. To address the issue, it is advisable to also check the class ofdocument.activeElement
. Specifically, if the classList of the element containsinput-clear-icon
, which identifies the clear input button, then focus should not be shifted away from it. This adjustment will ensure that focus remains on the clear input button as intended.The text was updated successfully, but these errors were encountered: