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

Combobox loses focus when option is selected with mouse click #2155

Closed
AnnaYuS opened this issue Jan 6, 2023 · 1 comment
Closed

Combobox loses focus when option is selected with mouse click #2155

AnnaYuS opened this issue Jan 6, 2023 · 1 comment
Assignees

Comments

@AnnaYuS
Copy link

AnnaYuS commented Jan 6, 2023

What package within Headless UI are you using?

@headlessui/vue

What version of that package are you using?

v1.7.7

What browser are you using?

Chrome

Reproduction URL

Screen.Recording.2023-01-06.at.18.10.43.mov

Describe your issue

Focus behaviour after an option is selected is different for keyboard and mouse interaction. I think when user selects option with mouse click the focus should stay on the input. At the moment the focus seems to go to the first tabbable element in the body.
There is also a discussion on this problem: #1984

@RobinMalfait RobinMalfait self-assigned this Jan 24, 2023
@RobinMalfait
Copy link
Member

Hey! Thank you for your bug report!
Much appreciated! 🙏

We had this behaviour before, but that would trigger the virtual keyboard again once the input got focus on mobile so we removed that in #1732.

The problem is that we can't keep the focus in the input itself because a tap on the option would move the focus so the solution is to re-focus the input field but that causes mobile issues as seen in #1732.

Maybe we can further improve it by detecting when somebody is on mobile or not but not 100% sure if it is worth it because there are a lot of false positives in even trying to detect this: laptops with touch screens, iPads with a keyboard attached, ... so going to keep it like this for now because I think that opening the keyboard on mobile and scrolling the page a bit is far more annoying than this issue on desktop.

Hope this makes sense!

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

No branches or pull requests

2 participants