Fixed button not being able to handle multiple children when asChild is done
This commit is contained in:
parent
9eacd3f9d6
commit
c36053dc55
1 changed files with 25 additions and 24 deletions
|
|
@ -66,30 +66,31 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|||
newChildren = toTitleCase(children);
|
||||
}
|
||||
return (
|
||||
<Comp
|
||||
className={buttonVariants({ variant, size: "none" })}
|
||||
ref={ref}
|
||||
{...props}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
loading ? "opacity-100" : "opacity-0",
|
||||
"absolute self-center",
|
||||
)}
|
||||
>
|
||||
<ForwardedIconComponent name={"Loader2"} className={"animate-spin"} />
|
||||
</div>
|
||||
<div
|
||||
className={cn(
|
||||
loading ? "opacity-0" : "opacity-100",
|
||||
buttonVariants({
|
||||
variant: "none",
|
||||
size,
|
||||
className: cn(buttonChildrenClasses, className),
|
||||
}),
|
||||
)}
|
||||
>
|
||||
{newChildren}
|
||||
<Comp ref={ref} {...props}>
|
||||
<div className={buttonVariants({ variant, size: "none" })}>
|
||||
<div
|
||||
className={cn(
|
||||
loading ? "opacity-100" : "opacity-0",
|
||||
"absolute self-center",
|
||||
)}
|
||||
>
|
||||
<ForwardedIconComponent
|
||||
name={"Loader2"}
|
||||
className={"animate-spin"}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className={cn(
|
||||
loading ? "opacity-0" : "opacity-100",
|
||||
buttonVariants({
|
||||
variant: "none",
|
||||
size,
|
||||
className: cn(buttonChildrenClasses, className),
|
||||
}),
|
||||
)}
|
||||
>
|
||||
{newChildren}
|
||||
</div>
|
||||
</div>
|
||||
</Comp>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue