Skip to content

Commit

Permalink
fix: avoid duplicating classs in nav-link merge-props
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Feb 5, 2025
1 parent a363e81 commit 3c34f99
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions components/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export const Link = forwardRef(function Link(
props: Readonly<LinkProps>,
forwardedRef: ForwardedRef<HTMLAnchorElement | HTMLSpanElement>,
): ReactNode {
/** Ensure `className` is passed to `mergProps` only once to avoid duplication. */
const { className: _, ...interactionProps } = props;

const ref = useRef<HTMLAnchorElement | HTMLSpanElement>(null);
const linkRef = useObjectRef(
useMemo(() => {
Expand All @@ -56,9 +59,9 @@ export const Link = forwardRef(function Link(
const isLinkElement = Boolean(props.href) && !isDisabled;
const ElementType: ElementType = isLinkElement ? LocaleLink : "span";

const { focusableProps } = useFocusable(props, linkRef);
const { pressProps, isPressed } = usePress({ ...props, ref: linkRef });
const { hoverProps, isHovered } = useHover(props);
const { focusableProps } = useFocusable(interactionProps, linkRef);
const { pressProps, isPressed } = usePress({ ...interactionProps, ref: linkRef });
const { hoverProps, isHovered } = useHover(interactionProps);
const { focusProps, isFocused, isFocusVisible } = useFocusRing();

const renderProps = useRenderProps({
Expand Down

0 comments on commit 3c34f99

Please sign in to comment.