hsuanyi-chou / shadcn-ui-expansions

More components built on top of shadcn-ui.
https://shadcnui-expansions.typeart.cc/
MIT License
1.06k stars 50 forks source link

No EmptyIdenticator shown when clicking the multi-selector and all options selected. #34

Closed GeorgThomassen closed 8 months ago

GeorgThomassen commented 9 months ago

When you pick all the options the EmptyIdenticator is shown:

EmptyIdenticator shown

However, when clicking the component again the EmptyIdenticator is not shown:

EmptyIdenticator not shown

It seems like the CommandEmpty is not kicking in

hsuanyi-chou commented 8 months ago

This is related to ComandEmpty of shadcn/ui.

I found a solution in cmdk issue #149

open Command.tsx and replace the CommandEmpty to following snippet

const CommandEmpty = React.forwardRef<
  HTMLDivElement,
  React.ComponentProps<typeof CommandPrimitive.Empty>
>(({ className, ...props }, forwardedRef) => {
  const render = useCommandState((state) => state.filtered.count === 0);

  if (!render) return null;

  return (
    <div
      ref={forwardedRef}
      className={cn('py-6 text-center text-sm', className)}
      cmdk-empty=""
      role="presentation"
      {...props}
    />
  );
});