Skip to content

chore: use forwardedAs prop in styled-react - #6910

Merged
francinelucca merged 33 commits into
mainfrom
chore/fix-forward-as-prop
Sep 30, 2025
Merged

chore: use forwardedAs prop in styled-react#6910
francinelucca merged 33 commits into
mainfrom
chore/fix-forward-as-prop

Conversation

@francinelucca

@francineluccafrancinelucca commented Sep 26, 2025

Copy link
Copy Markdown
Member

wraps all custom components in @primer/styled-react with forwardedAs prop to prevent issue caused by styled-components/styled-components#1981

Changelog

Changed

  • Modify all components in styled-react/src/components/* to use forwardedAs prop

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 26, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6cbe54b

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

This PR includes changesets to release 1 package
NameType
@primer/styled-reactPatch

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 26, 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!

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 implements forwardedAs prop handling in the styled-react package by creating wrapper components that pass the as prop as forwardedAs to styled components. This is necessary for proper polymorphic component behavior in styled-components.

  • Refactors all styled-react components to use a two-layer architecture (styled component + wrapper)
  • Adds consistent forwardedAs prop forwarding for polymorphic element rendering
  • Includes a minor Storybook port change from 6006 to 6007

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
packages/styled-react/src/components/UnderlineNav.tsxRefactored to use StyledUnderlineNav wrapper with forwardedAs support
packages/styled-react/src/components/Truncate.tsxAdded StyledTruncate wrapper with forwardedAs handling
packages/styled-react/src/components/ToggleSwitch.tsxCreated StyledToggleSwitch with forwardedAs prop forwarding
packages/styled-react/src/components/Timeline.tsxComprehensive refactor of all Timeline sub-components with forwardedAs support
packages/styled-react/src/components/SubNav.tsxAdded styled wrappers for SubNav and SubNavLink components
packages/styled-react/src/components/StateLabelProps.tsxFile deleted (appears to be duplicate/incorrect file)
packages/styled-react/src/components/StateLabel.tsxAdded StyledStateLabel wrapper with forwardedAs prop
packages/styled-react/src/components/Spinner.tsxRefactored to use StyledSpinner with forwardedAs handling
packages/styled-react/src/components/SegmentedControl.tsxAdded styled wrappers for all SegmentedControl sub-components
packages/styled-react/src/components/RelativeTime.tsxCreated StyledRelativeTime with forwardedAs support
packages/styled-react/src/components/RadioGroup.tsxComprehensive refactor of RadioGroup and all sub-components
packages/styled-react/src/components/PageHeader.tsxComplex refactor with forwardedAs support and type name changes
packages/styled-react/src/components/LinkButton.tsxAdded StyledLinkButton wrapper with forwardedAs prop
packages/styled-react/src/components/Header.tsxRefactored Header and sub-components with forwardedAs handling
packages/styled-react/src/components/Flash.tsxAdded StyledFlash wrapper with forwardedAs support
packages/styled-react/src/components/CounterLabel.tsxCreated StyledCounterLabel with forwardedAs prop
packages/styled-react/src/components/Checkbox.tsxAdded StyledCheckbox wrapper with forwardedAs handling
packages/react/package.jsonChanged Storybook dev server port from 6006 to 6007

Comment threadpackages/styled-react/src/components/UnderlineNav.tsx Outdated
Comment threadpackages/styled-react/src/components/PageHeader.tsx Outdated
Comment threadpackages/styled-react/src/components/PageHeader.tsx Outdated
Comment threadpackages/styled-react/src/components/Header.tsx
@github-actions
github-actionsBot requested a deployment to storybook-preview-6910 September 26, 2025 14:58 Abandoned

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

Copilot reviewed 18 out of 18 changed files in this pull request and generated 13 comments.

Comment threadpackages/styled-react/src/components/UnderlineNav.tsx Outdated
Comment threadpackages/styled-react/src/components/UnderlineNav.tsx Outdated
Comment threadpackages/styled-react/src/components/Timeline.tsx Outdated
Comment threadpackages/styled-react/src/components/Timeline.tsx Outdated
Comment threadpackages/styled-react/src/components/Timeline.tsx Outdated
Comment threadpackages/styled-react/src/components/PageHeader.tsx Outdated
Comment threadpackages/styled-react/src/components/RadioGroup.tsx Outdated
Comment threadpackages/styled-react/src/components/RadioGroup.tsx Outdated
Comment threadpackages/styled-react/src/components/RadioGroup.tsx Outdated
Comment threadpackages/styled-react/src/components/RadioGroup.tsx Outdated
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6910 September 26, 2025 15:07 Inactive
@github-actions
github-actionsBot requested a deployment to storybook-preview-6910 September 26, 2025 15:50 Abandoned
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6910 September 26, 2025 15:58 Inactive
@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 26, 2025
@github-actions
github-actionsBot requested a deployment to storybook-preview-6910 September 30, 2025 03:59 Abandoned
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6910 September 30, 2025 04:07 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-6910 September 30, 2025 04:15 Inactive
@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 30, 2025

@liuliu-devliuliu-dev 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.

Looks great! Thanks for the fix! 🎉 ❤️

@primer-integration

Copy link
Copy Markdown

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

@github-actionsgithub-actionsBot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh labels Sep 30, 2025
@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 30, 2025
@francinelucca
francinelucca added this pull request to the merge queueSep 30, 2025
Merged via the queue into main with commit 03c0c59Sep 30, 2025
43 of 44 checks passed
@francinelucca
francinelucca deleted the chore/fix-forward-as-prop branch September 30, 2025 17:34
@primerprimerBot mentioned this pull request Sep 30, 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/ghstaffAuthor is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@francinelucca@liuliu-dev@hectahertz