Skip to content

Remove sx from the SegmentedControl component - #6741

Merged
liuliu-dev merged 17 commits into
mainfrom
liuliu/remove-sx-from-segmentcontrol
Sep 11, 2025
Merged

Remove sx from the SegmentedControl component#6741
liuliu-dev merged 17 commits into
mainfrom
liuliu/remove-sx-from-segmentcontrol

Conversation

@liuliu-dev

@liuliu-devliuliu-dev commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

Remove sx from the SegmentedControl component
Closes#5834

sx usage, tracking here: https://github.com/github/primer/issues/5827

Screenshot 2025-09-10 at 9 30 49 AM

Rollout strategy

  • Major release; if selected, include a written rollout or migration plan

@changeset-bot

changeset-botBot commented Sep 5, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 32f40fe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
NameType
@primer/reactMajor
@primer/styled-reactMajor

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

@github-actions

Copy link
Copy Markdown
Contributor

👋 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!

@github-actionsgithub-actionsBot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Sep 5, 2025
@github-actions

github-actionsBot commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
packages/react/dist/browser.esm.js88.57 KB (-0.08% 🔽)
packages/react/dist/browser.umd.js88.63 KB (-0.11% 🔽)

@github-actionsgithub-actionsBot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Sep 8, 2025
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6741 September 8, 2025 18:14 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6741 September 8, 2025 20:15 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6741 September 8, 2025 20:23 Inactive
@liuliu-dev
liuliu-devforce-pushed the liuliu/remove-sx-from-segmentcontrol branch from 363f0f4 to 637b0d3CompareSeptember 8, 2025 20:32
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6741 September 8, 2025 20:40 Inactive
@github-actions
github-actionsBot requested a deployment to storybook-preview-6741 September 9, 2025 16:31 Abandoned
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6741 September 9, 2025 17:35 Inactive
@primer-integration

Copy link
Copy Markdown

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/2155

@primer-integration

Copy link
Copy Markdown

🟢 ci completed with status success.

@github-actionsgithub-actionsBot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: failing Changes in this PR cause breaking changes in gh/gh labels Sep 9, 2025
@liuliu-dev
liuliu-dev marked this pull request as ready for review September 9, 2025 23:21
CopilotAI review requested due to automatic review settings September 9, 2025 23:21
@liuliu-dev
liuliu-dev requested a review from a team as a code ownerSeptember 9, 2025 23:21

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the sx prop from the SegmentedControl component and its sub-components (Button and IconButton), aligning with the broader effort to phase out styled-system support from Primer React components. The change updates both the main React package and the styled-react compatibility package to maintain backwards compatibility.

  • Removes sx prop support from SegmentedControl, SegmentedControlButton, and SegmentedControlIconButton components
  • Adds compatibility wrappers in the styled-react package to preserve sx functionality for legacy consumers
  • Updates component exports, documentation, and tests to reflect the removal

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
packages/styled-react/src/index.tsxAdds SegmentedControl wrapper components that preserve sx prop functionality
packages/styled-react/src/tests/primer-react.browser.test.tsxUpdates tests to verify sx prop support in styled-react package
packages/react/src/index.tsExports SegmentedControl type definitions
packages/react/src/tests/snapshots/exports.test.ts.snapUpdates snapshot with new exported types
packages/react/src/SegmentedControl/index.tsExports component type definitions
packages/react/src/SegmentedControl/SegmentedControlIconButton.tsxRemoves sx prop and BoxWithFallback usage
packages/react/src/SegmentedControl/SegmentedControlButton.tsxRemoves sx prop and BoxWithFallback usage
packages/react/src/SegmentedControl/SegmentedControl.tsxRemoves sx prop, exports type, and removes BoxWithFallback usage
packages/react/src/SegmentedControl/SegmentedControl.docs.jsonRemoves sx prop from documentation
packages/react/src/SegmentedControl/SegmentedControl.dev.stories.tsxRemoves sx-related stories
e2e/components/SegmentedControl.test.tsRemoves tests for sx-related stories
.changeset/witty-chicken-leave.mdDocuments breaking change

Comment on lines +204 to +205
// Width is now handled by CSS: 32px default, 100% when data-full-width is set on parent
className={classes.IconButton}

CopilotAISep 9, 2025

Copy link

Choose a reason for hiding this comment

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

The comment mentions that width is handled by CSS using classes.IconButton, but this class is not defined in the visible changes and may not actually handle the width styling that was previously managed by the sx prop. This could result in incorrect styling behavior.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Reusing the IconButton className in SegmentedControl.module.css

@github-actions

github-actionsBot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Uh oh! @liuliu-dev, at least one image you shared is missing helpful alt text. Check your pull request body to fix the following violations:

  • Images should have meaningful alternative text (alt text) at line 8

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@liuliu-dev
liuliu-dev added this pull request to the merge queueSep 11, 2025
Merged via the queue into main with commit 4896ef1Sep 11, 2025
47 checks passed
@liuliu-dev
liuliu-dev deleted the liuliu/remove-sx-from-segmentcontrol branch September 11, 2025 21:32
@primerprimerBot mentioned this pull request Sep 11, 2025
pksjce pushed a commit that referenced this pull request Sep 18, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: passingChanges in this PR do NOT cause breaking changes in gh/gh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@liuliu-dev@pksjce@joshblack