Skip to content

Conversation

liuliu-dev
Copy link
Contributor

Adds browser tests to verify that styled-react components correctly handle the polymorphic as prop. Ensures styled-components wrappers maintain component behavior when rendering and provides test coverage for component-specific props preservation.

Current State

Tests currently fail for several components, reproducing the existing as prop forwarding issues in styled-react wrappers. PR #6910 should fix these test failures.

Copy link

changeset-bot bot commented Sep 26, 2025

⚠️ No Changeset found

Latest commit: eae2c6c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@liuliu-dev liuliu-dev added the skip changeset This change does not need a changelog label Sep 26, 2025
@github-actions github-actions bot requested a deployment to storybook-preview-6911 September 26, 2025 19:18 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-6911 September 26, 2025 19:26 Inactive
@liuliu-dev liuliu-dev changed the base branch from main to chore/fix-forward-as-prop September 26, 2025 19:31
@github-actions github-actions bot temporarily deployed to storybook-preview-6911 September 26, 2025 19:34 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-6911 September 26, 2025 19:44 Inactive
@liuliu-dev liuliu-dev marked this pull request as ready for review September 26, 2025 19:44
@liuliu-dev liuliu-dev requested a review from a team as a code owner September 26, 2025 19:44
Copy link
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-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Sep 26, 2025
@liuliu-dev liuliu-dev added integration-tests: skipped manually Changes in this PR do not require an integration test 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-actions bot temporarily deployed to storybook-preview-6911 September 26, 2025 22:21 Inactive
describe('@primer/react', () => {
test('ActionList supports `sx` prop', () => {
render(<ActionList data-testid="component" sx={{background: 'red'}} />)
render(<ActionList as="ul" data-testid="component" sx={{background: 'red'}} variant="inset" />)
Copy link
Member

Choose a reason for hiding this comment

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

This caught my eye, why do we need to explicitly set ActionList as="ul"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @siddharthkp, thanks for the review! Do you mean that we should use as="div" instead of the default ul for ActionList?

Copy link
Member

@siddharthkp siddharthkp Sep 29, 2025

Choose a reason for hiding this comment

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

No sorry, I meant why do we need to pass it any as prop? Does it no longer render a <ul> by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The as prop in this test is specifically to catch the polymorphic prop forwarding issue that the pattern in PR #6910 fixes, when you wrap a component with styled(), the as prop can get consumed by styled-components instead of being forwarded to the wrapped component, which causes component specific props to fail to be consumed correctly. That's why we add both as and variant here to test that variant is correctly passed.

Copy link
Member

Choose a reason for hiding this comment

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

Oh lol, my bad! That is literally what you are testing 😅

Do you mean that we should use as="div" instead of the default ul for ActionList?

This is a very good idea in that case!

Copy link
Member

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

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

@liuliu-dev liuliu-dev merged commit 30ffc4e into chore/fix-forward-as-prop Sep 29, 2025
38 of 39 checks passed
@liuliu-dev liuliu-dev deleted the liuliu/add-browser-tests-for-polymophic-components branch September 29, 2025 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: skipped manually Changes in this PR do not require an integration test skip changeset This change does not need a changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants