-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
fix: add value prop to commandItem to fix command search #1522
base: main
Are you sure you want to change the base?
Conversation
@ahmadghoniem is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
@SoyDiego hey, would love if you can take a look |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
is there anything i can help with so this can get merged |
If there's something that can be done from my end please let me know |
Fixes an issue with searching. Related: shadcn-ui/ui#1522
using Originally posted by @kulterryan in #1849 (comment) |
Hello, sorry, I have a problem with the search in the combobox, it turns out that I not only want to search by the value property, I also want to search by subtitle, but it doesn't work, it doesn't do the search correctly, I thank you if you help me, I want to have several values within an item and search for all of them at the same time, thank you very much:
|
This commit aims to fix all the search functionality problems occuring in all of the examples in ui.shadcn.com that have a
command (cmdk)
component used in it along with users installing newcommand
component from the CLI or manually installing them by copying.similar to #631 #1450 #173 but more general
live examples from ui.shadcn.com
command.mp4
combobox.mp4
playground-model-selection.mp4
cards-invite.mp4
REASON:
- With the value prop
the way the search functionality works is that if a
value prop
is provided toCommandItem
<CommandItem value="Calendar">Calendar</CommandItem>
the
value prop
value's gets stringified and passed to the implicitfilter prop
callback function as the value argument while search is the current value of the search input onCommand
see here cmdk-filterProp
backspacing triggers the filter callback function and everything works fine however
- Without the value prop
when omitting the value prop on
<CommandItem/>
the value prop takes the textContent of the CommandItem DOM element (see here: cmdk-textContent) and passes it to the filter function and it works TILL you try to use the backspace
backspacing doesn' t trigger the filter function and it produces the bug that you already have seen on the videos above
here's a brief video of solving the combobox example
solving-combobox.mp4