Skip to content

RAC: Autocomplete in Popover focus issues #7619

Open
@amitdahan

Description

Provide a general summary of the issue here

Love the new Autocomplete component! This used to require a lot of custom code on top of Menu, so we're eager to use it!

I tried playing with it, and found weird focus behavior when used in a Popover.

🤔 Expected Behavior?

When tabbing out of the popover menu, I'd expect the menu to close, just like when Menu (in a Popover and MenuTrigger) is used without Autocomplete.

😯 Current Behavior

I took the "classic" Menu example, added <Autocomplete> and <SearchField autoFocus><Input /></SearchField>.

In some cases, when I tab out of the menu - it correctly dismisses the menu, but sometimes (see repro) - it remains open, for example I could reach a state where I have 2 menus open at the same time due to this:

Image

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

I set up a repro here:
https://stackblitz.com/edit/vitejs-vite-cbycrt6c?file=src%2FMyMenu.tsx

Steps to see the problem:

  1. Tab in to the first menu trigger
  2. Press down, autocomplete correctly auto-focuses & up/down arrows work as expected
  3. Tab out of the menu, focus shifts to the 2nd menu trigger and previous menu closes (as expected)
  4. Press down, 2nd menu opens and works as expected
  5. Tab out of the menu - menu remains open, but we can keep tabbing, all the way back to the first menu trigger, and open it, while the 2nd menu is still open!
Screen.Recording.2025-01-16.at.11.41.27.mov

Version

RAC 1.6.0

What browsers are you seeing the problem on?

Chrome, Safari

If other, please specify.

No response

What operating system are you using?

macOS 15.3

🧢 Your Company/Team

Neon

🕷 Tracking Issue

No response

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions