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(input): clear button can be navigated using screen reader #29366

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,15 @@ export class Input implements ComponentInterface {
*/
ev.preventDefault();
}}
onFocusin={(ev) => {
/**
* Prevent the focusin event from bubbling otherwise it will cause the focusin
* event listener in scroll assist to fire. When this fires, focus will be moved
* back to the input even if the clear button was never tapped. This poses issues
* for screen readers as it means users would be unable to swipe past the clear button.
*/
ev.stopPropagation();
}}
onClick={this.clearTextInput}
>
<ion-icon aria-hidden="true" icon={mode === 'ios' ? closeCircle : closeSharp}></ion-icon>
Expand Down
10 changes: 5 additions & 5 deletions core/src/utils/input-shims/hacks/scroll-assist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const enableScrollAssist = (
const focusOut = () => {
hasKeyboardBeenPresentedForTextField = false;
win?.removeEventListener('ionKeyboardDidShow', keyboardShow);
componentEl.removeEventListener('focusout', focusOut, true);
componentEl.removeEventListener('focusout', focusOut);
};

/**
Expand Down Expand Up @@ -155,15 +155,15 @@ export const enableScrollAssist = (
);

win?.addEventListener('ionKeyboardDidShow', keyboardShow);
componentEl.addEventListener('focusout', focusOut, true);
componentEl.addEventListener('focusout', focusOut);
};

componentEl.addEventListener('focusin', focusIn, true);
componentEl.addEventListener('focusin', focusIn);

return () => {
componentEl.removeEventListener('focusin', focusIn, true);
componentEl.removeEventListener('focusin', focusIn);
win?.removeEventListener('ionKeyboardDidShow', keyboardShow);
componentEl.removeEventListener('focusout', focusOut, true);
componentEl.removeEventListener('focusout', focusOut);
};
};

Expand Down
Loading