diff --git a/apps/web/src/app/(dynamicPages)/entry/[category]/[author]/[permlink]/_components/entry-page-breadcrumb.tsx b/apps/web/src/app/(dynamicPages)/entry/[category]/[author]/[permlink]/_components/entry-page-breadcrumb.tsx index 7635ae976e..6168338159 100644 --- a/apps/web/src/app/(dynamicPages)/entry/[category]/[author]/[permlink]/_components/entry-page-breadcrumb.tsx +++ b/apps/web/src/app/(dynamicPages)/entry/[category]/[author]/[permlink]/_components/entry-page-breadcrumb.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import { IntentLink } from "@/features/shared/intent-link"; export interface BreadcrumbItem { name: string; @@ -34,9 +34,9 @@ export function EntryPageBreadcrumb({ items }: Props) { ) : ( <> - + {item.name} - + )} diff --git a/apps/web/src/features/shared/navbar/navbar-main-sidebar-toggle.tsx b/apps/web/src/features/shared/navbar/navbar-main-sidebar-toggle.tsx index d48b251f51..aa8498f820 100644 --- a/apps/web/src/features/shared/navbar/navbar-main-sidebar-toggle.tsx +++ b/apps/web/src/features/shared/navbar/navbar-main-sidebar-toggle.tsx @@ -2,7 +2,7 @@ import { Button } from "@/features/ui"; import { UilBars } from "@tooni/iconscout-unicons-react"; import i18next from "i18next"; import Image from "next/image"; -import Link from "next/link"; +import { IntentLink } from "@/features/shared/intent-link"; import defaults from "@/defaults"; interface Props { @@ -13,7 +13,7 @@ export function NavbarMainSidebarToggle({ onClick }: Props) { return (
); } diff --git a/apps/web/src/features/shared/navbar/navbar-mobile.tsx b/apps/web/src/features/shared/navbar/navbar-mobile.tsx index ef86b8f5d7..edc5281fed 100644 --- a/apps/web/src/features/shared/navbar/navbar-mobile.tsx +++ b/apps/web/src/features/shared/navbar/navbar-mobile.tsx @@ -17,7 +17,7 @@ import { Button } from "@ui/button"; import clsx from "clsx"; import i18next from "i18next"; import Image from "next/image"; -import Link from "next/link"; +import { IntentLink } from "@/features/shared/intent-link"; import { usePathname, useSearchParams } from "next/navigation"; import { useEffect, useState } from "react"; import defaults from "@/defaults"; @@ -132,11 +132,11 @@ export function NavbarMobile({ aria-label={i18next.t("navbar.toggle-menu")} aria-expanded={mainBarExpanded} /> - + {/* The image alt provides the link's accessible name (brand/home), distinct from the "Home" feed tab below. */} Ecency - + , router); + expect(router.prefetch).not.toHaveBeenCalled(); + }); + + it("prefetches on hover intent", async () => { + const router = makeRouter(); + await renderWithRouter(, router); + fireEvent.mouseEnter(screen.getByText("Perks").closest("a")!); + expect(router.prefetch).toHaveBeenCalledWith("/perks", expect.anything()); + }); +}); + +describe("Button href ref forwarding", () => { + it("forwards the ref through IntentLink to the anchor element", () => { + // React 19 passes ref as a prop through function components; IntentLink + // spreads it onto next/link, which attaches it to the rendered . + const ref = React.createRef(); + render( + + ); + expect(ref.current).toBeInstanceOf(HTMLAnchorElement); + expect(ref.current?.getAttribute("href")).toBe("/perks"); + }); +});