From 965d01fb32903cdc52a8e03d87439ad9606e1875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20S=C3=B6derberg?= Date: Tue, 17 Mar 2026 15:08:03 +0100 Subject: [PATCH] Fixed scroll glitch --- app/components/Navigation.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/components/Navigation.tsx b/app/components/Navigation.tsx index c2bae7f..e3cb315 100644 --- a/app/components/Navigation.tsx +++ b/app/components/Navigation.tsx @@ -5,7 +5,8 @@ import { Briefcase, Calendar, FileText, Home as HomeIcon, LifeBuoy, Lock, Map as MapIcon } from 'lucide-react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; -import { useEffect, useRef } from 'react'; +import { useEffect, useLayoutEffect, useRef } from 'react'; +const useSafeLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect; const NavItem = ({ to, icon: Icon, label, className = "" }: { to: string, icon: any, label: string, className?: string }) => { const pathname = usePathname(); @@ -29,7 +30,7 @@ export const Navigation = () => { const pathname = usePathname(); const navRef = useRef(null); - useEffect(() => { + useSafeLayoutEffect(() => { window.scrollTo({ top: 0, behavior: 'instant' }); }, [pathname]);