Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SegmentedControl uncontrolled by default #2189

Merged
merged 20 commits into from
Aug 11, 2022

Conversation

mperrotti
Copy link
Contributor

The SegmentedControl can now be functional without handling state externally.

Merge checklist

  • Added/updated tests
  • [n/a] Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • 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-bot
Copy link

changeset-bot bot commented Jul 26, 2022

🦋 Changeset detected

Latest commit: c50952d

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

@mperrotti mperrotti marked this pull request as ready for review July 26, 2022 15:05
@mperrotti mperrotti requested review from a team and siddharthkp July 26, 2022 15:05
@github-actions
Copy link
Contributor

github-actions bot commented Jul 26, 2022

size-limit report 📦

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

@mperrotti mperrotti temporarily deployed to github-pages July 26, 2022 15:14 Inactive
Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels really nice to use!! ✨

A few questions about the API here:

  1. 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)

  2. 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.

  3. 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

@siddharthkp siddharthkp dismissed their stale review July 27, 2022 15:07

Meant it to be a comment not changes requested

@mperrotti
Copy link
Contributor Author

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 mperrotti temporarily deployed to github-pages August 1, 2022 18:21 Inactive
@mperrotti mperrotti temporarily deployed to needs-approval August 1, 2022 19:15 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 1, 2022 19:23 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 2, 2022 13:47 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 2, 2022 16:20 Inactive
…m:primer/react into mp/segmented-control-default-uncontrolled
@mperrotti mperrotti temporarily deployed to github-pages August 5, 2022 18:49 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 5, 2022 19:22 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 5, 2022 19:24 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 8, 2022 15:53 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 8, 2022 15:54 Inactive
Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing on local machine, looking good!

quick question: I don't see keyboard navigation behavior from #2220 in this pull request. 🤔 I hope that's okay?

@mperrotti
Copy link
Contributor Author

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

I'll investigate

@mperrotti mperrotti temporarily deployed to github-pages August 10, 2022 15:23 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 10, 2022 15:24 Inactive
@mperrotti
Copy link
Contributor Author

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

@mperrotti mperrotti temporarily deployed to github-pages August 11, 2022 22:00 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 11, 2022 22:00 Inactive
@mperrotti mperrotti temporarily deployed to needs-approval August 11, 2022 22:09 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 11, 2022 22:15 Inactive
@mperrotti mperrotti temporarily deployed to github-pages August 11, 2022 22:17 Inactive
@mperrotti mperrotti merged commit 3571658 into main Aug 11, 2022
@mperrotti mperrotti deleted the mp/segmented-control-default-uncontrolled branch August 11, 2022 23:25
@primer-css primer-css mentioned this pull request Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants