Fixed scroll glitch

This commit is contained in:
2026-03-17 15:08:03 +01:00 Verified
parent e2dca92b48
commit 965d01fb32
+3 -2
View File
@@ -5,7 +5,8 @@
import { Briefcase, Calendar, FileText, Home as HomeIcon, LifeBuoy, Lock, Map as MapIcon } from 'lucide-react'; import { Briefcase, Calendar, FileText, Home as HomeIcon, LifeBuoy, Lock, Map as MapIcon } from 'lucide-react';
import Link from 'next/link'; import Link from 'next/link';
import { usePathname } from 'next/navigation'; 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 NavItem = ({ to, icon: Icon, label, className = "" }: { to: string, icon: any, label: string, className?: string }) => {
const pathname = usePathname(); const pathname = usePathname();
@@ -29,7 +30,7 @@ export const Navigation = () => {
const pathname = usePathname(); const pathname = usePathname();
const navRef = useRef<HTMLElement>(null); const navRef = useRef<HTMLElement>(null);
useEffect(() => { useSafeLayoutEffect(() => {
window.scrollTo({ top: 0, behavior: 'instant' }); window.scrollTo({ top: 0, behavior: 'instant' });
}, [pathname]); }, [pathname]);