pacocoursey / cmdk

Fast, unstyled command menu React component.
https://cmdk.paco.me
MIT License
9.04k stars 259 forks source link

command item duplicate name auto selected #174

Closed phongvudz closed 5 months ago

phongvudz commented 10 months ago

i think map key by id why item selected by name when i key up key down not work when item duplicate name

AyaanZaveri commented 9 months ago

Any solutions for this?

pacocoursey commented 5 months ago

i think map key by id why item selected by name when i key up key down not work when item duplicate name

What the fuck did I just read

can someone explain

pacocoursey commented 5 months ago

OK I re-read it a few times. It seems like you have two items that have the same content, like

<>
<Command.Item>Apple</Command.Item>
<Command.Item>Apple</Command.Item>
</>

You should use the value prop to differentiate them:

<>
<Command.Item value="apple-a">Apple</Command.Item>
<Command.Item value="apple-b">Apple</Command.Item>
</>