diff --git a/apps/web/src/modules/common/turbo-link.tsx b/apps/web/src/modules/common/turbo-link.tsx index e8ab1c6..8fc731a 100644 --- a/apps/web/src/modules/common/turbo-link.tsx +++ b/apps/web/src/modules/common/turbo-link.tsx @@ -8,6 +8,7 @@ import type { ComponentProps } from "react"; type TurboLinkProps = ComponentProps; export const TurboLink = ({ + onClick, onMouseEnter, onPointerEnter, onTouchStart, @@ -25,10 +26,26 @@ export const TurboLink = ({ } }; + const handleClick = (e: React.MouseEvent) => { + onClick?.(e); + if (e.defaultPrevented) return; + + const hash = strHref?.split("#")[1]; + if (hash) { + const el = document.getElementById(hash); + if (el) { + e.preventDefault(); + el.scrollIntoView({ behavior: "smooth" }); + window.history.pushState(null, "", `#${hash}`); + } + } + }; + return ( { conditionalPrefetch(); onMouseEnter?.(e); diff --git a/apps/web/src/modules/marketing/layout/header/header.tsx b/apps/web/src/modules/marketing/layout/header/header.tsx index a467573..3e4dba2 100644 --- a/apps/web/src/modules/marketing/layout/header/header.tsx +++ b/apps/web/src/modules/marketing/layout/header/header.tsx @@ -35,7 +35,7 @@ export const Header = () => { const { t } = useTranslation("marketing"); return ( -
+