Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions apps/studio.giselles.ai/components/ui/clickable-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,24 @@ interface ClickableTextProps
}

const ClickableText = forwardRef<HTMLButtonElement, ClickableTextProps>(
({ className, variant, asChild = false, ...props }, ref) => {
({ className, variant, asChild = false, type, ...props }, ref) => {
const Comp = asChild ? Slot : "button";
return (
<Comp
className={cn(clickableTextVariant({ variant, className }))}
ref={ref}
{...props}
/>
);
const sharedProps = {
className: cn(clickableTextVariant({ variant, className })),
ref,
};

if (asChild) {
return (
<Comp
{...sharedProps}
{...props}
{...(type !== undefined && { type })}
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional spread operator with undefined check is unnecessarily complex. Since Slot components pass through all props, you can simply spread type directly: {...props} already includes the type prop, making the conditional spread redundant.

Suggested change
{...(type !== undefined && { type })}

Copilot uses AI. Check for mistakes.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Inconsistent Prop Behavior Causes Form Submission Issues

When asChild is true, the type prop is only passed if explicitly defined, unlike the non-asChild case which defaults to type="button". This inconsistency means button elements used with asChild will default to type="submit", potentially causing unintended form submissions.

Fix in Cursor Fix in Web

/>
);
}

return <Comp {...sharedProps} {...props} type={type ?? "button"} />;
},
);
ClickableText.displayName = "ClickableText";
Expand Down