Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/chilly-knives-impress.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Add default `type="button"` for `Button`. This removes the implicit `type="submit"` for a `<button>` and requires an explicit `type` to change.
2 changes: 1 addition & 1 deletion src/Button/Button.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ import {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/po

const ButtonComponent = forwardRef(({children, ...props}, forwardedRef): JSX.Element => {
return (
<ButtonBase ref={forwardedRef} as="button" {...props}>
<ButtonBase ref={forwardedRef} as="button" type="button" {...props}>
{children}
</ButtonBase>
)
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/__snapshots__/Button.test.tsx.snap
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,7 @@ exports[`Button renders consistently 1`] = `

<button
className="c0"
type="button"
/>
`;

Expand DownExpand Up@@ -227,6 +228,7 @@ exports[`Button styles danger button appropriately 1`] = `

<button
class="c0"
type="button"
>
<span
data-component="text"
Expand DownExpand Up@@ -451,6 +453,7 @@ exports[`Button styles invisible button appropriately 1`] = `

<button
class="c0"
type="button"
>
<span
data-component="text"
Expand DownExpand Up@@ -581,6 +584,7 @@ exports[`Button styles outline button appropriately 1`] = `

<button
class="c0"
type="button"
>
<span
data-component="text"
Expand DownExpand Up@@ -706,6 +710,7 @@ exports[`Button styles primary button appropriately 1`] = `

<button
class="c0"
type="button"
>
<span
data-component="text"
Expand Down