fix(scroll-assist): allow focus on input's siblings #30409
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Issue number: internal
What is the current behavior?
If scroll assist is on (by default it is on for iOS mobile devices), then focus will be redirected to the input if a
focusIn
event fires within the component. This leads to some elements to not being accessible with screen readers.For example: When the clear button is focused, focusin is dispatched and bubbles up to the ion-input. Our scroll assist utility listens for focusin 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.
This issue was resolved via PR #29366. However, this only fixed the issue with the clear button. Since then,
ion-input
has implementedstart
andend
slots. This has opened up the possibility of other focusable elements to being present withinion-input
. The same issue applies to them. A great example of this is theinput-password-toggle
. The password toggle is required to have aslot="end"
to render appropriately withinion-input
. But the users can never access the toggle when using a screen reader.What is the new behavior?
Since we have no control of what is being passed within the the slots, the fix was done through the scroll assist instead of
ion-input
. It checks if any siblings of the native input have been focused, if they have then leave the focus on them instead of re-directing back to the native input.focusIn
code from the clear button since it's being handle at the scroll assist level.This fix will be introduced in a feature to lessen any possible issues in case of a regression.
Does this introduce a breaking change?
Other information
N/A