Adding a filter text input to a dropdown menu #787
Replies: 13 comments 23 replies
-
Hi @DaniGuardiola 👋 It sounds like you are trying to convert the We do have plans to build a Combobox, but it's not in progress at the moment I'm afraid 😞 |
Beta Was this translation helpful? Give feedback.
-
I just wanted to chime in and say we'd love a component like this as well. We ended up building our own Combobox component and then putting it inside of a radix DropdownMenu primitive. It mostly "just works" but there are definitely some rough edges around focus management. Ideally I'd love to see this as some sort of FilterableDropdownMenu primitive. Here's some screenshots: one of a top level menu and one within a submenu. |
Beta Was this translation helpful? Give feedback.
-
Just wanted to mention that adding |
Beta Was this translation helpful? Give feedback.
-
I tried something similar and it works fine but the input does not detect the spacebar onChange , it detects is onKeyDown but it's not being written and added to its value (not detected onChange) , this does not happen when the input is outside the dropdown trigger |
Beta Was this translation helpful? Give feedback.
-
for those who might be still looking on how to implement this pattern: cmdk plays pretty good with other radix primitives https://codesandbox.io/p/sandbox/radix-dropdown-combobox-1x6e3k?file=%2Fsrc%2FApp.css%3A5%2C7-5%2C12 |
Beta Was this translation helpful? Give feedback.
-
I'm waiting while using react-select first. |
Beta Was this translation helpful? Give feedback.
-
+1 also waiting on this! |
Beta Was this translation helpful? Give feedback.
-
+1 waiting on this! Until then, something like this can do the job; Except for escaping input focus with keyboard navigation :|
|
Beta Was this translation helpful? Give feedback.
-
Hi guys! |
Beta Was this translation helpful? Give feedback.
-
Just use react-select
…On Wed, Aug 7, 2024, 6:03 PM Drew ***@***.***> wrote:
Unfortunately, none of the approaches from this thread worked for me🫤
—
Reply to this email directly, view it on GitHub
<#787 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAVKVHLIAIDQ7DDACVNPCJLZQHWI3AVCNFSM5ATNYRF2U5DIOJSWCZC7NNSXTOSENFZWG5LTONUW63SDN5WW2ZLOOQ5TCMBSGYZDQMBT>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
If anyone still searching for answer and want to stick with Radix UI then Use Use Push all this inside a popover along with search box. |
Beta Was this translation helpful? Give feedback.
-
Hello. Thanks for the enlightening discussion here. I have a different use case, where I want to have an input field inside a dropdown, no for filtering, but to add an new option. I think that's should be a legitimate usecase here, isn't it? I managed to add the input into the dropdown and make sure focus stays there while typing. However, I'm struggling to make both keyboard and mouse interaction work. Keyboard navigation works with the following structure, but when the input it clicked, the dropdown is dismissed.
In the following example mouse interaction is as expected, but I cannot get focus on the input with the keyboard at all.
Any advise? |
Beta Was this translation helpful? Give feedback.
-
I'm trying to create a dropdown menu that contains a text input at the top to filter among the options. The main problem I've faced is that the typeahead feature is conflicting with it, and removes focus from the text input to give it to the corresponding menu item.
For example, if the options are "America", "Europe" and "Antarctica" and I start typing "Europe" in the input, as soon as I type the first "E" it will switch focus over to the "Europe" item.
This is my main problem for now, although I do want to implement a few other behaviors, like:
As I said, my main issue is the typeahead feature conflicting with the input. I've tried a bunch of things like preventing default, etc, but although I found some hacky ways to make it work, they all seem very fragile. How could I go about this?
My wishlist, in order of preference is:
Thoughts? Thanks in advance :)
Update: I sort of fixed it by setting
textValue
to""
(empty string) on all items. Still feels pretty hacky though, just sharing in case it's useful to anyone.Beta Was this translation helpful? Give feedback.
All reactions