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

[Dropdown Menu] Support for onOpenAutoFocus #3125

Open
sekeidesign opened this issue Sep 18, 2024 · 0 comments
Open

[Dropdown Menu] Support for onOpenAutoFocus #3125

sekeidesign opened this issue Sep 18, 2024 · 0 comments

Comments

@sekeidesign
Copy link

Feature request

Overview

We recently replaced our own Popover component to be built on top of react-dropdown-menu instead of react-popover since the two are almost identical, but the DropdownMenu also supports Submenus which is definitely something we want.

The migration was essentially free since both of these components share the vast majority of functionality and props, with the exception of onOpenAutoFocus.

We use onOpenAutoFocus to prevent the Popover from grabbing focus in our Combobox which then uses the Input trigger's onBlur event to close the Popover.

Example:

CleanShot.2024-09-18.at.14.33.53.mp4
import * as RadixPopover from '@radix-ui/react-popover'
...
<RadixPopover.Content 
    onOpenAutoFocus={event => {
        if (preventAutoFocus) {
            event.preventDefault()
        }
    }}
...
>

Compared with dropdown-menu

CleanShot.2024-09-18.at.14.36.57.mp4
import * as RadixPopover from '@radix-ui/react-dropdown-menu'
...
<RadixPopover.Content 
    // onOpenAutoFocus not supported!
...
>

Everything else is exactly the same and fully supported without any changes anywhere in our codebase.

Examples in other libraries

Radix already supports this in other "popover" style components:
https://www.radix-ui.com/primitives/docs/components/popover#content

Who does this impact? Who is this for?

It's a helpful event for managing focus that right now prevents us from using this component for our combobox.

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

1 participant