Skip to content

Commit

Permalink
add type="button" to all components using button element (#150)
Browse files Browse the repository at this point in the history
add default type="button" to all components using button element
  • Loading branch information
wysher authored Oct 30, 2023
1 parent 5bd3afb commit 6a1e214
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-laws-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

add default type="button" to all components using button element
1 change: 1 addition & 0 deletions src/lib/bits/accordion/components/AccordionTrigger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-keydown={dispatch}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{:else}
<button
use:melt={builder}
type="button"
on:m-click={dispatch}
on:m-keydown={dispatch}
{...$$restProps}
Expand Down
1 change: 1 addition & 0 deletions src/lib/bits/checkbox/components/Checkbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{#if asChild}
<slot {builder} {attrs} />
{:else}
<button use:melt={builder} {...$$restProps} {...attrs} on:m-click={dispatch}>
<button use:melt={builder} type="button" {...$$restProps} {...attrs} on:m-click={dispatch}>
<slot {builder} {attrs} />
</button>
{/if}
1 change: 1 addition & 0 deletions src/lib/bits/dialog/components/DialogClose.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
1 change: 1 addition & 0 deletions src/lib/bits/dialog/components/DialogTrigger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-keydown={dispatch}
Expand Down
1 change: 1 addition & 0 deletions src/lib/bits/menubar/components/MenubarTrigger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
7 changes: 4 additions & 3 deletions src/lib/bits/popover/components/PopoverClose.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { melt } from "@melt-ui/svelte";
import { getCtx, getAttrs } from "../ctx.js";
import type { TriggerEvents, TriggerProps } from "../types.js";
import type { CloseProps, CloseEvents } from "../types.js";
import { createDispatcher } from "$lib/internal/events.js";
type $$Props = TriggerProps;
type $$Events = TriggerEvents;
type $$Props = CloseProps;
type $$Events = CloseEvents;
export let asChild = false;
const {
elements: { close }
Expand All @@ -20,6 +20,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
1 change: 1 addition & 0 deletions src/lib/bits/popover/components/PopoverTrigger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bits/popover/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ContentProps<
> = Expand<TransitionProps<T, In, Out> & AsChild> & HTMLDivAttributes;

type TriggerProps = AsChild & HTMLButtonAttributes;
type CloseProps = AsChild & HTMLButtonAttributes;
type CloseProps = TriggerProps;

type ArrowProps = Expand<
{
Expand Down
1 change: 1 addition & 0 deletions src/lib/bits/radio-group/components/RadioGroupItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
1 change: 1 addition & 0 deletions src/lib/bits/select/components/SelectTrigger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
1 change: 1 addition & 0 deletions src/lib/bits/switch/components/Switch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
1 change: 1 addition & 0 deletions src/lib/bits/tabs/components/TabsTrigger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/bits/tabs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
OmitValue,
OnChangeFn
} from "$lib/internal/index.js";
import type { HTMLButtonAttributes } from "svelte/elements";
import type { CustomEventHandler } from "$lib/index.js";

type Props = Expand<
Expand All @@ -25,7 +26,7 @@ type ContentProps = Expand<
> &
HTMLDivAttributes;

type TriggerProps = Expand<ObjectVariation<TabsTriggerProps> & AsChild> & HTMLDivAttributes;
type TriggerProps = Expand<ObjectVariation<TabsTriggerProps> & AsChild> & HTMLButtonAttributes;

type ListProps = AsChild & HTMLDivAttributes;

Expand Down
1 change: 1 addition & 0 deletions src/lib/bits/toggle/components/Toggle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-click={dispatch}
Expand Down
1 change: 1 addition & 0 deletions src/lib/bits/tooltip/components/TooltipTrigger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{:else}
<button
use:melt={builder}
type="button"
{...$$restProps}
{...attrs}
on:m-blur={dispatch}
Expand Down

0 comments on commit 6a1e214

Please sign in to comment.