Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 5 #6273

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Patch 5 #6273

wants to merge 2 commits into from

Conversation

RahimGuerfi
Copy link
Contributor

PR Title:

refactor(registry): merge className props in CommandEmpty component


Description:

This PR introduces a small but essential refactor in the CommandEmpty component located in command.tsx. Previously, the className prop was passed directly to the component, which caused any custom className provided to overwrite the default className.

To fix this, I updated the implementation to extract the className prop and merge it with the default classes using the cn utility. This ensures that custom className values are appended rather than overwriting the defaults.


Changes Made:

  • Updated the CommandEmpty component to merge className props instead of overwriting them:
    const CommandEmpty = React.forwardRef<
      React.ElementRef<typeof CommandPrimitive.Empty>,
      React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
    >(({ className, ...props }, ref) => (
      <CommandPrimitive.Empty
        ref={ref}
        className={cn("py-6 text-center text-sm", className)}
        {...props}
      />
    ));

Benefits:

  • Prevents overwriting default styles when a className prop is provided.
  • Ensures consistent styling across components while allowing customizations.

Steps to Test:

  1. Use the CommandEmpty component in a project and pass a className prop.
  2. Verify that the default className values are preserved and the custom classes are appended correctly.

Checklist:

  • Verified that the component's behavior is consistent after the changes.
  • Tested merging of className values in various scenarios.
  • No breaking changes introduced.

Copy link

vercel bot commented Jan 4, 2025

@RahimGuerfi is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant