fix(Button): default htmlType to button to prevent accidental form submission#1141
Open
munzzyy wants to merge 2 commits into
Open
fix(Button): default htmlType to button to prevent accidental form submission#1141munzzyy wants to merge 2 commits into
munzzyy wants to merge 2 commits into
Conversation
Button and IconButton both accept an htmlType prop but never defaulted it, so the native button fell back to the browser default of type=submit. Any Button or IconButton inside a form submitted that form on click unless htmlType was set explicitly. Default htmlType to 'button' on both components. Consumers who want submit behavior still opt in with htmlType="submit". Closes ClickHouse#1092
🦋 Changeset detectedLatest commit: 8fade1c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
ariser
reviewed
Jul 6, 2026
Collaborator
There was a problem hiding this comment.
SplitButtonhas this prop as well https://github.com/ClickHouse/click-ui/blob/main/src/components/SplitButton/SplitButton.types.ts#L38- This is a breaking change, we should not just merge it without a migration plan for consumers. We can't assume all use cases that expect default submit behavior are covered by tests. This can break silently.
ariser
reviewed
Jul 6, 2026
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| '@clickhouse/click-ui': patch | |||
Extends the Button/IconButton fix to SplitButton, which has the same submit-by-default gap. Bumped the changeset from patch to minor since defaulting htmlType is a behavior change for any consumer relying on the old default-submit fallback.
Author
|
Good catches, both fixed:
Full suite (505 tests) and typecheck both pass locally. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
A native
<button>without an explicittypedefaults totype="submit".Button,IconButton, andSplitButtonall accept anhtmlTypeprop, but it was never defaulted, so it stayedundefinedand the browser fell back tosubmit. Any of these rendered inside a<form>submits that form on click unless a caller remembers to passhtmlType="button". #1126 added thehtmlTypeescape hatch and fixed a bunch of internal button usages, but left this specific default gap open, and the current test suite documents it directly (Button.test.tsx/IconButton.test.tsxboth had a test literally titled "should not default to any type... thus behaving as type=submit").Closes #1092.
How?
htmlType = 'button'in the destructured props ofButton,IconButton, andSplitButton.Button/IconButton: the old test asserted the buggy submit-by-default behavior, now it asserts the button does not submit by default and thattype="button"is on the element. Added matching coverage toSplitButton.test.tsx, which had no test for the default case at all.htmlType="submit"still submits the form when set explicitly.FileTabs,Select'sInternalSelect,Table) — they already passhtmlType="button"explicitly, so this default doesn't change their behavior.patchtominorper @ariser's review: this changes runtime behavior for any consumer who was relying on the old default-submit fallback, so it's not safe to treat as a patch. Called it out explicitly in the changeset body.Tickets?
Contribution checklist?
buildcommand runs locallySecurity checklist?
dangerouslySetInnerHTMLPreview?
N/A — behavior-only change (default prop value), no visual change.
yarn test(full suite, 505 tests) andyarn typecheckboth pass locally.