Skip to content
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

feat(Button): add default type #2807

Merged
merged 4 commits into from
Jan 26, 2023
Merged

feat(Button): add default type #2807

merged 4 commits into from
Jan 26, 2023

Conversation

joshblack
Copy link
Member

Closes #2806

Update the default type for Button to be "button". By default, buttons are inferred to be of type="submit" which can cause some unexpected behavior, especially within forms.

Changelog

New

Changed

  • Add type="button" to Button.tsx

Removed

@joshblack joshblack requested review from a team and mperrotti January 24, 2023 15:48
@changeset-bot
Copy link

changeset-bot bot commented Jan 24, 2023

🦋 Changeset detected

Latest commit: a5be8b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jan 24, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 88.87 KB (+0.01% 🔺)
dist/browser.umd.js 89.48 KB (+0.01% 🔺)

Copy link
Contributor

@langermank langermank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this is a breaking change potentially?

@joshblack
Copy link
Member Author

@langermank I think if someone relies on inferred type="submit" then unfortunately yeah, it could be considered one 😞

@joshblack joshblack temporarily deployed to github-pages January 24, 2023 15:55 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2807 January 24, 2023 15:56 Inactive
Copy link
Contributor

@iansan5653 iansan5653 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Regarding moving this to ButtonBase instead: I don't think it's necessary because ButtonBase is only used elsewhere in LinkButton (which renders as an a tag) and some deprecated components.

This is theoretically a breaking change but I've personally never seen anyone rely on the implicit submit type of a button. I'd be surprised if this is done anywhere.

@joshblack joshblack temporarily deployed to github-pages January 24, 2023 19:22 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2807 January 24, 2023 19:22 Inactive
@joshblack
Copy link
Member Author

I think we can try this out in the upcoming release and see how it lands, happy to revert it back if it becomes problematic!

@joshblack joshblack enabled auto-merge (squash) January 26, 2023 18:51
@joshblack joshblack merged commit 81447a1 into main Jan 26, 2023
@joshblack joshblack deleted the joshblack-patch-1 branch January 26, 2023 18:58
@joshblack joshblack temporarily deployed to github-pages January 26, 2023 18:58 — with GitHub Actions Inactive
@primer-css primer-css mentioned this pull request Jan 26, 2023
@mattcosta7
Copy link
Collaborator

I go 50/50 on this, but agreed with feeling it out

I always think html is weird here by defaulting type to submit in forms, but also that consistency with html is nice (even though it's non-intuitive)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Button component has no default type
5 participants