Skip to content

fix(Link): destructure muted prop to prevent unintentional DOM attribute leakage#7631

Open
Copilot wants to merge 3 commits intomainfrom
copilot/fix-muted-prop-leak
Open

fix(Link): destructure muted prop to prevent unintentional DOM attribute leakage#7631
Copilot wants to merge 3 commits intomainfrom
copilot/fix-muted-prop-leak

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

  • Add assertion to the existing muted test that the bare muted HTML attribute is not present on the DOM element

This can cause hydration errors and warnings (where ssr or csr might not serialize it properly)

Original prompt

Bug

In packages/react/src/Link/Link.tsx, the muted prop is not destructured out of restProps, causing it to leak to the DOM element via the {...restProps} spread.

Current code (line 23):

const {as: Component = 'a', className, inline, hoverColor, ...restProps} = props

inline and hoverColor are correctly extracted, but muted is not. Later in the JSX:

<Component
  className={clsx(className, classes.Link)}
  data-muted={restProps.muted}   // reads muted from restProps
  data-inline={inline}
  data-hover-color={hoverColor}
  {...restProps}                  // ⚠️ spreads restProps which STILL contains `muted`
  ref={innerRef as any}
/>

This means the rendered DOM element gets both data-muted="true" (intentional, used by CSS) and a bare muted HTML attribute (unintentional). React may warn: "Warning: Received 'true' for a non-boolean attribute 'muted'.".

Fix

Destructure muted from props alongside inline and hoverColor:

const {as: Component = 'a', className, inline, muted, hoverColor, ...restProps} = props

And update the JSX to use the extracted muted variable:

<Component
  className={clsx(className, classes.Link)}
  data-muted={muted}
  data-inline={inline}
  data-hover-color={hoverColor}
  {...restProps}
  ref={innerRef as any}
/>

This ensures muted is consumed by the component and only passed to the DOM as the data-muted data attribute, which is what the CSS module (Link.module.css) expects.

This pull request was created from Copilot chat.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@changeset-bot
Copy link

changeset-bot bot commented Mar 6, 2026

⚠️ No Changeset found

Latest commit: 61eb747

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

Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix muted prop leaking into DOM element fix(Link): destructure muted prop to prevent unintentional DOM attribute leakage Mar 6, 2026
Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
@mattcosta7 mattcosta7 marked this pull request as ready for review March 6, 2026 05:38
@mattcosta7 mattcosta7 requested a review from a team as a code owner March 6, 2026 05:38
@mattcosta7 mattcosta7 requested review from Copilot and hectahertz March 6, 2026 05:38
Copy link
Contributor

Copilot AI left a comment

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 fixes a bug in the Link component where the muted prop was not destructured from restProps, causing it to leak as a bare HTML attribute on the DOM element. This could trigger React warnings about non-boolean attributes.

Changes:

  • Destructure muted from props alongside inline and hoverColor in Link.tsx, and reference the extracted variable for data-muted
  • Add a test assertion verifying the bare muted attribute is not present on the rendered DOM element

Reviewed changes

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

File Description
packages/react/src/Link/Link.tsx Destructures muted from props to prevent DOM attribute leakage; updates data-muted to use the extracted variable
packages/react/src/Link/__tests__/Link.test.tsx Adds assertion to existing "muted" test to verify the bare muted attribute is absent from the DOM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants