Make SegmentedControl uncontrolled by default
The SegmentedControl can now be functional without handling state externally.
Merge checklist
- [x] Added/updated tests
- [n/a] Added/updated documentation
- [x] Tested in Chrome
- [x] Tested in Firefox
- [x] Tested in Safari
- [ ] Tested in Edge
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.
🦋 Changeset detected
Latest commit: c50952d63d4c0b1e15cc226308fead893e560860
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 |
|---|---|
| dist/browser.esm.js | 72.96 KB (0%) |
| dist/browser.umd.js | 73.33 KB (0%) |
When the component can change the selected button by itself (uncontrolled), should the prop selected be called defaultSelected instead? (like value and defaultValue for input)
Yup, we should add defaultSelected as a prop.
Do we have a recommended way of firing actions? onChange on the parent vs onClick on the buttons? We should reflect the preferred approach in the examples.
onChange on the parent. I'll update the examples.
Depending on the answer for 1 + 2, should we have both selected and defaultSelected similar to value + defaultValue where value is the controlled version that needs to be managed via onChange
Yes, we should have selected and defaultSelected, and selected will be managed via onChange for controlled components.
Thanks again @siddharthkp! I've addressed your feedback.
@siddharthkp - that doesn't seem right... 🤔
I'll investigate
@siddharthkp - I'm seeing that behavior in the preview deployment