-
Couldn't load subscription status.
- Fork 50
fix: default ClickableText button type to "button" #1963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 })} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Inconsistent Prop Behavior Causes Form Submission IssuesWhen |
||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return <Comp {...sharedProps} {...props} type={type ?? "button"} />; | ||
| }, | ||
| ); | ||
| ClickableText.displayName = "ClickableText"; | ||
|
|
||
There was a problem hiding this comment.
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
typedirectly:{...props}already includes the type prop, making the conditional spread redundant.