ui icon indicating copy to clipboard operation
ui copied to clipboard

[Bug]: Command/Combobox TypeError and Unclickable/Disabled items, cmdk breaking change

Open blackhatcobol opened this issue 1 year ago • 7 comments

Describe the bug

Why I faced Disabled items with no reason ?

Affected component/components

Command, combobox, CommandItem

How to reproduce

Right click on The component <CommanItem>, chose: Go to Definition F12, then: Go to the Component tailwind styling, then: Remove the following classes from the className 👍🏻 : "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", or change the [disabled] data to [true] 🥇 Congrats ! You solved your issue.

Codesandbox/StackBlitz link

please add a reproduction

Logs

nothing

System Info

nothing

Before submitting

  • [X] I've made research efforts and searched the documentation
  • [X] I've searched for existing issues

blackhatcobol avatar Mar 16 '24 03:03 blackhatcobol

i also encountered same bug when i use combobox. "data-[disabled]:pointer-events-none" this class added "opacity:50%" and "pointer-events: none" with no reason.

muhammedalibilgin avatar Mar 16 '24 09:03 muhammedalibilgin

fix is removing data-[disabled]:pointer-events-none and data-[disabled]:opacity-50 class . Should work now

Rehan-shah avatar Mar 16 '24 13:03 Rehan-shah

@Rehan-shah Yes, that works.

ademhatay avatar Mar 17 '24 00:03 ademhatay

FYI the fix is simply to target the data-disabled="true" state rather than just the presence of data-disabled which is what the current CSS is doing.

data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50

As per the cmdk release, they now specify true/false instead of leaving it undefined. See - https://github.com/pacocoursey/cmdk/releases/tag/v1.0.0

Just update the CommandItem tailwind line to this

const CommandItem = React.forwardRef<
  React.ElementRef<typeof CommandPrimitive.Item>,
  React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
>(({ className, ...props }, ref) => (
  <CommandPrimitive.Item
    ref={ref}
    className={cn(
      'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50',
      className
    )}
    {...props}
  />
));

AdiRishi avatar Mar 19 '24 12:03 AdiRishi

I'd simply replace data-[disabled] to aria-disabled which handles true/false already like aria-selected

image

ApacheEx avatar Mar 20 '24 09:03 ApacheEx

omg thank you!

tonnoz avatar Mar 27 '24 22:03 tonnoz