Skip to content

chore(LinkButton): remove sx from LinkButton - #6866

Merged
francinelucca merged 11 commits into
mainfrom
chore/remove-sx-from-linkbutton
Sep 22, 2025
Merged

chore(LinkButton): remove sx from LinkButton#6866
francinelucca merged 11 commits into
mainfrom
chore/remove-sx-from-linkbutton

Conversation

@francinelucca

@francineluccafrancinelucca commented Sep 17, 2025

Copy link
Copy Markdown
Member

Closes#6767

Remove sx from the LinkButton component

Current sx usage: 0

✅ Don't need to separately update github-ui components to use @primer/styled-react

Changelog

Changed

  • LinkButton export in @primer/styled-react to support removed sx prop

Removed

  • sx prop from LinkButton

Rollout strategy

  • 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

Merge checklist

@changeset-bot

changeset-botBot commented Sep 17, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9dbbe29

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-actionsgithub-actionsBot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Sep 17, 2025
@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!

francineluccaand others added 2 commits September 17, 2025 19:22
Co-authored-by: Josh Black <joshblack@users.noreply.github.com>
@github-actions
github-actionsBot requested a deployment to storybook-preview-6866 September 19, 2025 03:29 Abandoned
@primer-integration

Copy link
Copy Markdown

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

@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: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Sep 19, 2025
@francinelucca
francinelucca marked this pull request as ready for review September 19, 2025 04:42

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

Purpose: Remove the sx prop from @primer/react's LinkButton (breaking change) while preserving backward compatibility for styled-system consumers via a styled-react wrapper that reintroduces sx support.

Key changes:

  • Removed sx handling from LinkButton implementation in @primer/react and updated its exported prop types.
  • Added a styled-react LinkButton wrapper that reattaches sx via styled-components.
  • Updated exports, snapshot, story usage, and added a changeset marking a major release.

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/styled-react/src/index.tsxRe-exports custom styled-react LinkButton with sx support and its props.
packages/styled-react/src/components/LinkButton.tsxIntroduces styled-components wrapper to reintroduce sx prop.
packages/react/src/Button/LinkButton.tsxRemoves sx prop from core LinkButton implementation.
packages/react/src/Button/index.tsExports new LinkButtonProps type.
packages/react/src/tests/snapshots/exports.test.ts.snapUpdates snapshot to include new exported type.
packages/react/src/ButtonGroup/ButtonGroup.dev.stories.tsxReplaces deprecated sx usage with inline style in story.
eslint.config.mjsAdjusts ignore path for polymorphic helper filename change.
.changeset/stale-avocados-enjoy.mdDeclares semver impact (major/minor) for the change.


type LinkButtonProps = PrimerLinkButtonProps & SxProp

const LinkButton: ForwardRefComponent<'a', LinkButtonProps> = styled(PrimerLinkButton)<LinkButtonProps>`

CopilotAISep 19, 2025

Copy link

Choose a reason for hiding this comment

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

The styled wrapper forwards the sx prop directly to PrimerLinkButton, which no longer declares or consumes sx; PrimerLinkButton spreads remaining props to ButtonBase, risking an invalid sx attribute reaching the DOM (e.g., ). Filter out sx before forwarding: either use withConfig({shouldForwardProp: prop => prop !== 'sx'}) or wrap the inner component: const LinkButton = styled(({sx, ...rest}) => <PrimerLinkButton {...rest} />)${sx} to prevent leaking sx to the DOM.

Suggested change
constLinkButton: ForwardRefComponent<'a',LinkButtonProps>=styled(PrimerLinkButton)<LinkButtonProps>`
constLinkButton: ForwardRefComponent<'a',LinkButtonProps>=styled(({sx, ...rest})=><PrimerLinkButton{...rest}/>)<LinkButtonProps>`

Copilot uses AI. Check for mistakes.
Comment threadpackages/react/src/Button/LinkButton.tsx
@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 22, 2025
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks!

@francinelucca
francinelucca added this pull request to the merge queueSep 22, 2025
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6866 September 22, 2025 17:40 Inactive
Merged via the queue into main with commit 3237a4eSep 22, 2025
40 of 41 checks passed
@francinelucca
francinelucca deleted the chore/remove-sx-from-linkbutton branch September 22, 2025 17:47
@primerprimerBot mentioned this pull request Sep 22, 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/ghintegration-tests: recommendedThis change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpmstaffAuthor is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove support for sx from the LinkButton component

3 participants

@francinelucca@siddharthkp