ui icon indicating copy to clipboard operation
ui copied to clipboard

(BUG) Handling empty state for searching in <Command />

Open Sukrittt opened this issue 2 years ago • 5 comments
trafficstars

Description

  • Once you search for an item which is not there in the displayed list, it will display the <CommandEmpty /> content.
  • But when we backspace and start writing the correct item name, the <CommandEmpty /> content is still being displayed even though there are items.
  • I have to clear my query and then start typing again.

Steps to reproduce

  1. Start typing something with a letter which is there in the item and then type something else, such that it shows 'No results found'.
  2. Then backspace and type the correct item name.
  3. The items will not be displayed even though there are items matching the query.

Sukrittt avatar Oct 07 '23 08:10 Sukrittt

I found this issue, but it has some different behaviors depending on the options you have in your options list.

  • Search Works perfectly when i have a list where both the label and value are the same, both of type String.
  • but with the value is a number, it has different behaviors, i tried to put my own search method, the difference is that sometimes the backspace triggers the execution, and sometimes it doesn't.

i hope it can be fixed soon.

youneszahzouh avatar Oct 10 '23 15:10 youneszahzouh

I found this issue, but it has some different behaviors depending on the options you have in your options list.

  • Search Works perfectly when i have a list where both the label and value are the same, both of type String.
  • but with the value is a number, it has different behaviors, i tried to put my own search method, the difference is that sometimes the backspace triggers the execution, and sometimes it doesn't.

i hope it can be fixed soon.

it was fixed when i changed the value in CommandItem to item.lable instead of item.value

<CommandItem ...restOfProps value={item.label} > {item.label} </CommandItem>

youneszahzouh avatar Oct 10 '23 16:10 youneszahzouh

I was able to reproduce in https://ui.shadcn.com/docs/components/command

image

image

image

Also happens if you type something which is not there, and then select everything and start typing the correct work (without using backspace).

image

image

image

Yet it works in https://cmdk.paco.me/

miquelvir avatar Oct 21 '23 18:10 miquelvir

Related with #1754

miquelvir avatar Oct 21 '23 19:10 miquelvir

Duplicate of #1450

miquelvir avatar Oct 21 '23 19:10 miquelvir

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Feb 24 '24 23:02 shadcn