diff --git a/components/TempDesignSystem/Link/index.tsx b/components/TempDesignSystem/Link/index.tsx index 8ef6452da..6856f87aa 100644 --- a/components/TempDesignSystem/Link/index.tsx +++ b/components/TempDesignSystem/Link/index.tsx @@ -1,7 +1,7 @@ "use client" import NextLink from "next/link" import { usePathname, useRouter } from "next/navigation" -import { startTransition, useCallback, useEffect } from "react" +import { startTransition, useCallback } from "react" import useRouterTransitionStore from "@/stores/router-transition" @@ -60,15 +60,21 @@ export default function Link({ prefetch={prefetch} className={classNames} onClick={(e) => { + if (onClick) { + onClick(e) + } + if (trackingId) { + trackClickById() + } + if (props.target === "_blank") { + // If link should open in new tab, we don't want to + // track navigation nor start a router transition. + return + } + e.preventDefault() trackPageViewStart() startTransition(() => { startRouterTransition() - if (trackingId) { - trackClickById() - } - if (onClick) { - onClick(e) - } router.push(href) }) }}