react icon indicating copy to clipboard operation
react copied to clipboard

Make SegmentedControl uncontrolled by default

Open mperrotti opened this issue 3 years ago • 5 comments

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.

mperrotti avatar Jul 26 '22 15:07 mperrotti

🦋 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

changeset-bot[bot] avatar Jul 26 '22 15:07 changeset-bot[bot]

size-limit report 📦

Path Size
dist/browser.esm.js 72.96 KB (0%)
dist/browser.umd.js 73.33 KB (0%)

github-actions[bot] avatar Jul 26 '22 15:07 github-actions[bot]

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.

mperrotti avatar Aug 01 '22 17:08 mperrotti

Thanks again @siddharthkp! I've addressed your feedback.

mperrotti avatar Aug 03 '22 22:08 mperrotti

@siddharthkp - that doesn't seem right... 🤔

I'll investigate

mperrotti avatar Aug 10 '22 15:08 mperrotti

@siddharthkp - I'm seeing that behavior in the preview deployment

mperrotti avatar Aug 11 '22 21:08 mperrotti