Skip to content

Commit 81447a1

Browse files
authored
feat(Button): add default type (#2807)
* feat(Button): add default type * Create .changeset/chilly-knives-impress.md * test: update snapshots Co-authored-by: Josh Black <joshblack@users.noreply.github.com>
1 parent 0173404 commit 81447a1

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": minor
3+
---
4+
5+
Add default `type="button"` for `Button`. This removes the implicit `type="submit"` for a `<button>` and requires an explicit `type` to change.

src/Button/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/po
55

66
const ButtonComponent = forwardRef(({children, ...props}, forwardedRef): JSX.Element => {
77
return (
8-
<ButtonBase ref={forwardedRef} as="button" {...props}>
8+
<ButtonBase ref={forwardedRef} as="button" type="button" {...props}>
99
{children}
1010
</ButtonBase>
1111
)

src/__tests__/__snapshots__/Button.test.tsx.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ exports[`Button renders consistently 1`] = `
104104
105105
<button
106106
className="c0"
107+
type="button"
107108
/>
108109
`;
109110

@@ -227,6 +228,7 @@ exports[`Button styles danger button appropriately 1`] = `
227228
228229
<button
229230
class="c0"
231+
type="button"
230232
>
231233
<span
232234
data-component="text"
@@ -451,6 +453,7 @@ exports[`Button styles invisible button appropriately 1`] = `
451453
452454
<button
453455
class="c0"
456+
type="button"
454457
>
455458
<span
456459
data-component="text"
@@ -581,6 +584,7 @@ exports[`Button styles outline button appropriately 1`] = `
581584
582585
<button
583586
class="c0"
587+
type="button"
584588
>
585589
<span
586590
data-component="text"
@@ -706,6 +710,7 @@ exports[`Button styles primary button appropriately 1`] = `
706710
707711
<button
708712
class="c0"
713+
type="button"
709714
>
710715
<span
711716
data-component="text"

0 commit comments

Comments
 (0)