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

[Select] Select closes when on-screen keyboard is shown #2634

Open
georgekaran opened this issue Jan 6, 2024 · 0 comments · May be fixed by #2635
Open

[Select] Select closes when on-screen keyboard is shown #2634

georgekaran opened this issue Jan 6, 2024 · 0 comments · May be fixed by #2635

Comments

@georgekaran
Copy link

Bug report

Current Behavior

When using a mobile device, showing the on-screen keyboard causes the Select close every time.

WhatsApp.Video.Jan.6.mp4

Expected behavior

It should not close the Select when opening the on-screen keyboard.

Reproducible example

  1. On a mobile device go to the sandbox https://codesandbox.io/p/devbox/beautiful-night-sss6gx
  2. Open the Select
  3. Click on the "Search items" input
  4. The Select will instantly close.

Suggested solution

Additional context

After a bit of debugging I've found that the resize event is triggering whenever the on-screen keyboard is shown.

React.useEffect(() => {
const close = () => onOpenChange(false);
window.addEventListener('blur', close);
window.addEventListener('resize', close);
return () => {
window.removeEventListener('blur', close);
window.removeEventListener('resize', close);
};
}, [onOpenChange]);

Your environment

Software Name(s) Version
Radix Package(s) react-select 2.0.0
React n/a
Browser Google Chrome 120.0.6099.145
Assistive tech
Node n/a
npm/yarn Yarn 1.22.19
Operating System Android 13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant