fix(FormControl): allow required check boxes
Relates to https://github.com/github/primer/issues/3470
FormControl by design does not allow individual Checkbox/Radio to be required. As per:
- https://github.com/github/primer/issues/3470#issuecomment-2362018592
- https://github.com/primer/react/pull/5027#discussion_r1787922994 there may be use cases where an individual
Checkboxcan be required individually or within aCheckboxGroup(since multiple checkboxes can be checked at once, opposed to radio buttons). This PR introduces functionality toFormControlallow that behavior to happen.
Changelog
New
- Adds
FormControltests for required prop used with individual and group checkboxes
Changed
- Updates choice group checks in
FormControlto determine if the input is aCheckboxand pass down therequiredprop in which case - Updates
CheckboxGroupPlayground story to showcase one required Checkbox within a CheckboxGroup - Updates
CheckboxGroupstory snapshots to account forrequiredchange
Rollout strategy
- [x] Patch release
- [ ] Minor release
- [ ] Major release; if selected, include a written rollout or migration plan
- [ ] None; if selected, include a brief description as to why
Testing & Reviewing
- Verify required checkbox within CheckboxGroup playground story, notice required prop on input in DOM.
- There should be no visual changes to
FormControl,CheckboxorCheckboxGroup - Verify Default FormControl story now properly marks
requiredattribute on checkbox
Merge checklist
- [x] Added/updated tests
- [ ] Added/updated documentation
- [x] Added/updated previews (Storybook)
- [ ] Changes are SSR compatible
- [x] Tested in Chrome
- [ ] Tested in Firefox
- [ ] Tested in Safari
- [ ] Tested in Edge
- [x] (GitHub staff only) Integration tests pass at github/github (Learn more about how to run integration tests)
🦋 Changeset detected
Latest commit: f7433a2b32e103e2b11a212a99d8d22ca8648ba6
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 | Patch |
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
size-limit report 📦
| Path | Size |
|---|---|
| packages/react/dist/browser.esm.js | 97.31 KB (-0.31% 🔽) |
| packages/react/dist/browser.umd.js | 97.51 KB (-0.29% 🔽) |
:wave: Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!
:wave: Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/346259
🟢 golden-jobs completed with status success.