fix(frontend): forward refs through shadcn bridge buttons

This commit is contained in:
Sagit
2026-02-19 05:55:54 +00:00
parent b6c2159614
commit 2308b25bcf
3 changed files with 71 additions and 54 deletions
+15 -10
View File
@@ -37,16 +37,21 @@ type ButtonProps = React.ComponentProps<"button"> &
asChild?: boolean;
};
function Button({ asChild = false, className, size, variant, ...props }: ButtonProps) {
const Comp = asChild ? Slot : "button";
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ asChild = false, className, size, variant, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
return (
<Comp
className={cn(buttonVariants({ className, size, variant }))}
data-slot="button"
{...props}
/>
);
}
return (
<Comp
className={cn(buttonVariants({ className, size, variant }))}
data-slot="button"
ref={ref}
{...props}
/>
);
},
);
Button.displayName = "Button";
export { Button, buttonVariants };