Repository navigation
Conversation
|
@cpruijsen is attempting to deploy a commit to the WorkOS Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Going to close this. Not planning to keep it rebased. |
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.
Do not paste this section header. Paste from Title down.
Title: Prevent Checkbox from submitting forms when given a type prop
Description
Checkboxis a styled Radix checkbox primitive: a<button>plus a hidden bubble<input type="checkbox">. Spreading a native-inputtype(for example Conform'sgetInputProps(field, { type: "checkbox" })) forwardedtype="checkbox"onto the button. Browsers treat that invalid button type assubmit, so clicking the checkbox submitted the enclosing form.The trigger now always renders
type="button", after the leftover-prop spread, the same way this component already forcesasChild={false}.typeis omitted from the public prop type so it is not part of the documented API. A spread from an untyped or wider object is still ignored at runtime.What I chose: ignore/override
typeon the button rather than forwarding it to the hidden input.Alternative: apply
typeto the bubble input, as suggested on #711.Why: that input is already
type="checkbox"inside@radix-ui/react-checkboxand is not exposed by Themes. Forwarding it would require forking the primitive, and for the reportedtype: "checkbox"case it would not change anything.Happy to lock
Switch/CheckboxGroup.Item/CheckboxCards.Item/RadioGroup.Itemthe same way if you want one PR to cover every button-based form control. I left those alone as out of scope for #711.Testing steps
/test/checkbox-typein the playground.buttonwithtype="button"(not"checkbox"/"submit").0.1.apps/playground:pnpm exec playwright test tests/checkbox.spec.ts --project=chromium.Relates issues / PRs