Skip to content

Autocomplete input focus is inconsistent #8198

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

Open
Szulerinio opened this issue May 6, 2025 · 1 comment
Open

Autocomplete input focus is inconsistent #8198

Szulerinio opened this issue May 6, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@Szulerinio
Copy link

Provide a general summary of the issue here

Autocomplete input focus is inconsistent. Sometimes clicking the input field adds data-focused="true" attribute, sometimes it doesn't.

🤔 Expected Behavior?

data-focused="true" should be consistently added to input on input click

😯 Current Behavior

After hovering any option, clicking the input field doesn't focus it until a key is pressed.
After pressing a key, the input field can again be focused until any option is hovered

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

visit autocomplete's storybook
Path 1:
click the input field without hovering any option - it becomes focused
hover any option - option becomes focused. Input field loses focus and is unable to be focused until any keypress is provided to the input
Path 2:
hover any option - both Input field and option become focused
click out of the autocomplete box - both lose the focus. Input field is unable to be focused until any keypress is provided to the input

the same behavior occurs in docs

Version

react-aria-components: "1.8.0"

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

mac

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@LFDanLu LFDanLu added the bug Something isn't working label May 7, 2025
@github-project-automation github-project-automation bot moved this to 🩺 To Triage in RSP Component Milestones May 7, 2025
@LFDanLu LFDanLu moved this to 🩺 To Triage in RSP Component Milestones May 7, 2025
@LFDanLu
Copy link
Member

LFDanLu commented May 7, 2025

Seems to be a bug in how we handle the virtual focus between the input and the items in the list. We dispatch virtual blur events between the input and the items in the list in an effort to make sure only one or the other has visible focus but that inadvertently causes the input field to lose isFocused rather than just isFocusVisible when the item is focused (in this case via hover). We could opt for including custom information in the dispatched events perhaps to inform useFocusRing that it should be changing isFocusVisible instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🩺 To Triage
Development

No branches or pull requests

2 participants