diff --git a/.changeset/tame-lions-blend.md b/.changeset/tame-lions-blend.md new file mode 100644 index 00000000000..c82a7526310 --- /dev/null +++ b/.changeset/tame-lions-blend.md @@ -0,0 +1,5 @@ +--- +'@primer/react': patch +--- + +Add test to validate that the `muted` prop is not leaked as a bare DOM attribute on `Link` diff --git a/packages/react/src/Link/Link.tsx b/packages/react/src/Link/Link.tsx index 1680afb2eb1..65d08ac1424 100644 --- a/packages/react/src/Link/Link.tsx +++ b/packages/react/src/Link/Link.tsx @@ -18,7 +18,7 @@ export const UnwrappedLink = ( props: PolymorphicProps, ref: ForwardedRef, ) => { - const {as: Component = 'a', className, inline, hoverColor, ...restProps} = props + const {as: Component = 'a', className, inline, muted, hoverColor, ...restProps} = props const innerRef = React.useRef>(null) useRefObjectAsForwardedRef(ref, innerRef) @@ -49,7 +49,7 @@ export const UnwrappedLink = ( return ( { it('respects the "muted" prop', () => { const {container} = render() expect(container.firstChild).toHaveAttribute('data-muted', 'true') + expect(container.firstChild).not.toHaveAttribute('muted') }) it('logs a warning when trying to render invalid "as" prop', () => {