Skip to content

Commit 0ab16c6

Browse files
committed
fix: add type="button" to button with no asChild
1 parent 20aee3c commit 0ab16c6

15 files changed

+11
-30
lines changed

app/components/ui/button.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function Button({
7272
return (
7373
<Comp
7474
data-slot="button"
75+
type={!asChild ? 'button' : undefined}
7576
className={cn(buttonVariants({ variant, size, className }))}
7677
disabled={loading || disabled}
7778
{...props}

app/components/ui/calendar.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ function Nav({ className }: NavProps) {
209209
<Button
210210
variant="secondary"
211211
className="absolute left-0 h-7 w-7 bg-transparent p-0 opacity-80 hover:opacity-100"
212-
type="button"
213212
tabIndex={isPreviousDisabled ? undefined : -1}
214213
disabled={isPreviousDisabled}
215214
aria-label={labelPrevious(previousMonth)}
@@ -221,7 +220,6 @@ function Nav({ className }: NavProps) {
221220
<Button
222221
variant="secondary"
223222
className="absolute right-0 h-7 w-7 bg-transparent p-0 opacity-80 hover:opacity-100"
224-
type="button"
225223
tabIndex={isNextDisabled ? undefined : -1}
226224
disabled={isNextDisabled}
227225
aria-label={labelNext(nextMonth)}

app/components/ui/confirm-responsive-drawer.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default {
1111
export function Default() {
1212
return (
1313
<ConfirmResponsiveDrawer onConfirm={() => alert('Custom Action')}>
14-
<Button type="button">Confirm</Button>
14+
<Button>Confirm</Button>
1515
</ConfirmResponsiveDrawer>
1616
);
1717
}
@@ -25,7 +25,7 @@ export function WithCustomProps() {
2525
confirmText="Custom Text"
2626
confirmVariant="destructive"
2727
>
28-
<Button type="button">Trigger Modal</Button>
28+
<Button>Trigger Modal</Button>
2929
</ConfirmResponsiveDrawer>
3030
);
3131
}
@@ -46,7 +46,7 @@ export function EnabledProps() {
4646
onConfirm={() => alert('Custom Action')}
4747
enabled={enabled}
4848
>
49-
<Button type="button">{enabled ? 'Confirm' : 'Without confirm'}</Button>
49+
<Button>{enabled ? 'Confirm' : 'Without confirm'}</Button>
5050
</ConfirmResponsiveDrawer>
5151
</div>
5252
);
@@ -57,7 +57,7 @@ export function WithPromise() {
5757
<ConfirmResponsiveDrawer
5858
onConfirm={async () => new Promise((r) => setTimeout(r, 2000))}
5959
>
60-
<Button type="button">Confirm</Button>
60+
<Button>Confirm</Button>
6161
</ConfirmResponsiveDrawer>
6262
);
6363
}

app/components/ui/confirm-responsive-drawer.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,12 @@ export const ConfirmResponsiveDrawer = (props: {
9898
</ResponsiveDrawerHeader>
9999
<ResponsiveDrawerFooter>
100100
<ResponsiveDrawerClose asChild>
101-
<Button
102-
type="button"
103-
size="lg"
104-
variant="secondary"
105-
className="max-sm:w-full"
106-
>
101+
<Button size="lg" variant="secondary" className="max-sm:w-full">
107102
{props.cancelText ??
108103
t('components:confirmResponsiveDrawer.cancelText')}
109104
</Button>
110105
</ResponsiveDrawerClose>
111106
<Button
112-
type="button"
113107
size="lg"
114108
variant={props.confirmVariant ?? 'default'}
115109
className="max-sm:w-full"

app/components/ui/datalist.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export const EmptyState = () => {
189189
<DataListEmptyState>
190190
<div className="flex flex-col items-center justify-center gap-x-2 gap-y-1">
191191
<p className="self-center">Let&apos;s add your first user</p>
192-
<Button type="button" variant="ghost" size="sm">
192+
<Button variant="ghost" size="sm">
193193
<PlusIcon />
194194
New User
195195
</Button>
@@ -269,7 +269,7 @@ const ExampleMenu = () => {
269269
return (
270270
<DropdownMenu>
271271
<DropdownMenuTrigger asChild>
272-
<Button type="button" size="icon-sm" variant="ghost" className="-m-1">
272+
<Button size="icon-sm" variant="ghost" className="-m-1">
273273
<EllipsisIcon />
274274
</Button>
275275
</DropdownMenuTrigger>

app/components/ui/datalist.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export const DataListErrorState = ({
142142
<div className="flex w-full flex-col items-center gap-x-2 gap-y-1 text-muted-foreground">
143143
{!!children && <div className="text-sm">{children}</div>}
144144
{!!retry && (
145-
<Button type="button" variant="ghost" size="sm" onClick={retry}>
145+
<Button variant="ghost" size="sm" onClick={retry}>
146146
<LucideRefreshCw />
147147
{t('components:datalist.retry')}
148148
</Button>
@@ -169,7 +169,6 @@ export const DataListRowResults = (props: {
169169
</DataListText>
170170
{!!props.withClearButton && (
171171
<Button
172-
type="button"
173172
variant="ghost"
174173
size="xs"
175174
onClick={() => {

app/components/ui/dropdown-menu.stories.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ export const Default = () => {
1818
return (
1919
<DropdownMenu>
2020
<DropdownMenuTrigger asChild>
21-
<Button variant="secondary" type="button">
22-
Open
23-
</Button>
21+
<Button variant="secondary">Open</Button>
2422
</DropdownMenuTrigger>
2523
<DropdownMenuContent>
2624
<DropdownMenuLabel>My Account</DropdownMenuLabel>

app/components/ui/local-switcher.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const LocalSwitcher = (props: { iconOnly?: boolean }) => {
1919
<DropdownMenu>
2020
<DropdownMenuTrigger asChild>
2121
<Button
22-
type="button"
2322
variant={props.iconOnly ? 'ghost' : 'link'}
2423
size={props.iconOnly ? 'icon' : 'default'}
2524
>

app/components/ui/search-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const SearchButtonComponent = ({
4141
}}
4242
>
4343
<DrawerTrigger asChild>
44-
<Button type="button" size="icon" variant="ghost" {...props}>
44+
<Button size="icon" variant="ghost" {...props}>
4545
{loading ? <Spinner /> : <SearchIcon />}
4646
<span className="sr-only">Search</span> {/* TODO translation */}
4747
</Button>

app/components/ui/theme-switcher.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export const ThemeSwitcher = (props: { iconOnly?: boolean }) => {
4040
<DropdownMenu>
4141
<DropdownMenuTrigger asChild>
4242
<Button
43-
type="button"
4443
variant={props.iconOnly ? 'ghost' : 'link'}
4544
size={props.iconOnly ? 'icon' : 'default'}
4645
>

0 commit comments

Comments
 (0)