Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Link): Do not pass through hoverColor prop in Link #5319

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-garlics-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Do not pass through hoverColor prop into DOM element
4 changes: 3 additions & 1 deletion packages/react/src/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type StyledLinkProps = {
inline?: boolean
} & SxProp

const Link = forwardRef(({as: Component = 'a', className, inline, underline, ...props}, forwardedRef) => {
const Link = forwardRef(({as: Component = 'a', className, inline, underline, hoverColor, ...props}, forwardedRef) => {
const innerRef = React.useRef<HTMLAnchorElement>(null)
useRefObjectAsForwardedRef(forwardedRef, innerRef)

Expand Down Expand Up @@ -53,6 +53,7 @@ const Link = forwardRef(({as: Component = 'a', className, inline, underline, ...
data-muted={props.muted}
data-inline={inline}
data-underline={underline}
data-hover-color={hoverColor}
Copy link
Member

Choose a reason for hiding this comment

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

does this need a css counterpart or does it just work? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't believe it's actually being used any longer since it is deperecated, this just ensures that we don't pass in an invalid attribute into the dom

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks for explaining that!
Do we gain anything by adding the data-hover-holor then? could we just ignore the prop?

{...props}
// @ts-ignore shh
ref={innerRef}
Expand All @@ -66,6 +67,7 @@ const Link = forwardRef(({as: Component = 'a', className, inline, underline, ...
data-muted={props.muted}
data-inline={inline}
data-underline={underline}
data-hover-color={hoverColor}
{...props}
// @ts-ignore shh
ref={innerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`Link passes href down to link element 1`] = `
exports[`Link respects hoverColor prop 1`] = `
<a
className="Link"
hoverColor="accent.fg"
data-hover-color="accent.fg"
/>
`;

Expand Down
Loading