pacocoursey / cmdk

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

[Bug] MultiSelectorItem duplicate child #291

Open thangdevalone opened 4 months ago

thangdevalone commented 4 months ago

image When I hover on the Item it affects 2 items with the same child

iamabhshk commented 3 months ago

Shall I work on this issue? @pacocoursey

Akhilathina commented 1 month ago

Yes I am also facing the same issue

Akhilathina commented 1 month ago

`const CommandItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef

(({ className, ...props }, ref) => ( <CommandPrimitive.Item ref={ref} className={cn( 'relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground', className, )} key={props.value} {...props} /> ));`

I am using shadcn components, Using key to give unique value to Item solves the issue

iampava commented 1 week ago

I encountered the same issue. The solution was to have a unique value passed to Command.Item and a different one rendered in the UI.