From e6e9a6772bf81cf5a67dbba785e7250553b56839 Mon Sep 17 00:00:00 2001 From: Thomas Alberola Date: Sun, 12 Nov 2023 11:56:52 +0100 Subject: [PATCH] Move className overwrite of AccordionContent to the children component (#1670) In order to have a smooth opening of the accordion, moving the `AccordionContent` `className` overwrite to the children wrapper component allow Radix to calculate correctly the animation and execute a smooth animation in case of `className` on the `AccordionContent` component. Possibly related to https://github.com/shadcn-ui/ui/issues/944 --- apps/www/public/registry/styles/default/accordion.json | 2 +- apps/www/public/registry/styles/new-york/accordion.json | 2 +- apps/www/registry/default/ui/accordion.tsx | 8 +++----- apps/www/registry/new-york/ui/accordion.tsx | 7 ++----- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/apps/www/public/registry/styles/default/accordion.json b/apps/www/public/registry/styles/default/accordion.json index 4ed833abf8..5482c2118c 100644 --- a/apps/www/public/registry/styles/default/accordion.json +++ b/apps/www/public/registry/styles/default/accordion.json @@ -6,7 +6,7 @@ "files": [ { "name": "accordion.tsx", - "content": "\"use client\"\n\nimport * as React from \"react\"\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\"\nimport { ChevronDown } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Accordion = AccordionPrimitive.Root\n\nconst AccordionItem = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, ...props }, ref) => (\n \n))\nAccordionItem.displayName = \"AccordionItem\"\n\nconst AccordionTrigger = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, children, ...props }, ref) => (\n \n svg]:rotate-180\",\n className\n )}\n {...props}\n >\n {children}\n \n \n \n))\nAccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName\n\nconst AccordionContent = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, children, ...props }, ref) => (\n \n
{children}
\n \n))\nAccordionContent.displayName = AccordionPrimitive.Content.displayName\n\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent }\n" + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\"\nimport { ChevronDown } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Accordion = AccordionPrimitive.Root\n\nconst AccordionItem = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, ...props }, ref) => (\n \n))\nAccordionItem.displayName = \"AccordionItem\"\n\nconst AccordionTrigger = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, children, ...props }, ref) => (\n \n svg]:rotate-180\",\n className\n )}\n {...props}\n >\n {children}\n \n \n \n))\nAccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName\n\nconst AccordionContent = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, children, ...props }, ref) => (\n \n
{children}
\n \n))\n\nAccordionContent.displayName = AccordionPrimitive.Content.displayName\n\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent }\n" } ], "type": "components:ui" diff --git a/apps/www/public/registry/styles/new-york/accordion.json b/apps/www/public/registry/styles/new-york/accordion.json index 49a913fb94..d6bf8b0fd2 100644 --- a/apps/www/public/registry/styles/new-york/accordion.json +++ b/apps/www/public/registry/styles/new-york/accordion.json @@ -6,7 +6,7 @@ "files": [ { "name": "accordion.tsx", - "content": "\"use client\"\n\nimport * as React from \"react\"\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\"\nimport { ChevronDownIcon } from \"@radix-ui/react-icons\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Accordion = AccordionPrimitive.Root\n\nconst AccordionItem = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, ...props }, ref) => (\n \n))\nAccordionItem.displayName = \"AccordionItem\"\n\nconst AccordionTrigger = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, children, ...props }, ref) => (\n \n svg]:rotate-180\",\n className\n )}\n {...props}\n >\n {children}\n \n \n \n))\nAccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName\n\nconst AccordionContent = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, children, ...props }, ref) => (\n \n
{children}
\n \n))\nAccordionContent.displayName = AccordionPrimitive.Content.displayName\n\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent }\n" + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\"\nimport { ChevronDownIcon } from \"@radix-ui/react-icons\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Accordion = AccordionPrimitive.Root\n\nconst AccordionItem = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, ...props }, ref) => (\n \n))\nAccordionItem.displayName = \"AccordionItem\"\n\nconst AccordionTrigger = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, children, ...props }, ref) => (\n \n svg]:rotate-180\",\n className\n )}\n {...props}\n >\n {children}\n \n \n \n))\nAccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName\n\nconst AccordionContent = React.forwardRef<\n React.ElementRef,\n React.ComponentPropsWithoutRef\n>(({ className, children, ...props }, ref) => (\n \n
{children}
\n \n))\nAccordionContent.displayName = AccordionPrimitive.Content.displayName\n\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent }\n" } ], "type": "components:ui" diff --git a/apps/www/registry/default/ui/accordion.tsx b/apps/www/registry/default/ui/accordion.tsx index 937620af27..24c788c2c4 100644 --- a/apps/www/registry/default/ui/accordion.tsx +++ b/apps/www/registry/default/ui/accordion.tsx @@ -46,15 +46,13 @@ const AccordionContent = React.forwardRef< >(({ className, children, ...props }, ref) => ( -
{children}
+
{children}
)) + AccordionContent.displayName = AccordionPrimitive.Content.displayName export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } diff --git a/apps/www/registry/new-york/ui/accordion.tsx b/apps/www/registry/new-york/ui/accordion.tsx index 66f095a7b8..8dcf9b6fa5 100644 --- a/apps/www/registry/new-york/ui/accordion.tsx +++ b/apps/www/registry/new-york/ui/accordion.tsx @@ -46,13 +46,10 @@ const AccordionContent = React.forwardRef< >(({ className, children, ...props }, ref) => ( -
{children}
+
{children}
)) AccordionContent.displayName = AccordionPrimitive.Content.displayName