fix: PageHeader.ParentLink forwards rest props to support polymorphic as routing#7978
fix: PageHeader.ParentLink forwards rest props to support polymorphic as routing#7978Copilot wants to merge 2 commits into
as routing#7978Conversation
…c as routing Co-authored-by: adierkens <13004162+adierkens@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 3ad321c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
as routing
|
There was a problem hiding this comment.
Pull request overview
Fixes PageHeader.ParentLink prop forwarding so it behaves consistently with other polymorphic Primer components (e.g. allowing React Router-style to when using a custom as component), instead of silently dropping unknown props.
Changes:
- Update
PageHeader.ParentLinkto collect...restprops and spread them onto the underlyingLink. - Add unit tests verifying arbitrary props (e.g.
data-testid) and customasprops (e.g.to) are forwarded correctly. - Add a patch changeset for
@primer/react.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/PageHeader/PageHeader.tsx | Forwards remaining props from ParentLink onto Link, enabling polymorphic routing props like to. |
| packages/react/src/PageHeader/PageHeader.test.tsx | Adds regression tests ensuring rest props and custom as props are forwarded to the rendered link. |
| .changeset/pageheader-parentlink-rest-props.md | Declares a patch release note for the ParentLink prop-forwarding fix. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 0
|
Integration test results from github/github-ui PR:
All checks passed! |
PageHeader.ParentLinkdestructured a fixed prop set and never spread the remainder onto the underlyingLink, silently dropping any prop not in the allowlist — includingtoused by React Router. This broke the standard polymorphic pattern that works onButton,Link, andNavList.Item.Changes
PageHeader.tsx— Add...resttoParentLink's destructuring and spread it onto<Link>after the explicit props, matching the pattern used by other polymorphic Primer componentsPageHeader.test.tsx— Add two tests: one verifying arbitrary props (data-testid) reach the rendered element; one verifying a customascomponent receives forwarded props (to).changeset/pageheader-parentlink-rest-props.md— Patch changesetChangelog
New
Changed
PageHeader.ParentLinknow forwards unknown/rest props to the underlying element, consistent with other polymorphic Primer componentsRemoved
Rollout strategy
Testing & Reviewing
Two new unit tests cover the fix:
data-testidforwarded via defaultas="a"ascomponent (simulating a routerLink) receivestoand renders the correcthrefMerge checklist