Fixed button not being able to handle multiple children when asChild is done

This commit is contained in:
Lucas Oliveira 2024-06-04 10:26:52 -03:00
commit c36053dc55

View file

@ -66,18 +66,18 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
newChildren = toTitleCase(children); newChildren = toTitleCase(children);
} }
return ( return (
<Comp <Comp ref={ref} {...props}>
className={buttonVariants({ variant, size: "none" })} <div className={buttonVariants({ variant, size: "none" })}>
ref={ref}
{...props}
>
<div <div
className={cn( className={cn(
loading ? "opacity-100" : "opacity-0", loading ? "opacity-100" : "opacity-0",
"absolute self-center", "absolute self-center",
)} )}
> >
<ForwardedIconComponent name={"Loader2"} className={"animate-spin"} /> <ForwardedIconComponent
name={"Loader2"}
className={"animate-spin"}
/>
</div> </div>
<div <div
className={cn( className={cn(
@ -91,6 +91,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
> >
{newChildren} {newChildren}
</div> </div>
</div>
</Comp> </Comp>
); );
}, },