diff --git a/components/navigation-progress.tsx b/components/navigation-progress.tsx index 1ec01e5..d8564ff 100644 --- a/components/navigation-progress.tsx +++ b/components/navigation-progress.tsx @@ -8,10 +8,11 @@ import { useMemo, useRef, useState, + Suspense, type MutableRefObject, type ReactNode, } from "react"; -import { usePathname } from "next/navigation"; +import { usePathname, useSearchParams } from "next/navigation"; const SHOW_DELAY_MS = 120; const MIN_VISIBLE_MS = 180; @@ -32,12 +33,22 @@ function clearTimer(timerRef: MutableRefObject) { } } +function NavigationProgressComplete({ onComplete }: { onComplete: () => void }) { + const pathname = usePathname(); + const searchParams = useSearchParams(); + + useEffect(() => { + onComplete(); + }, [pathname, searchParams, onComplete]); + + return null; +} + export function NavigationProgressProvider({ children, }: { children: ReactNode; }) { - const pathname = usePathname(); const [visible, setVisible] = useState(false); const visibleRef = useRef(false); const shownAtRef = useRef(0); @@ -93,10 +104,6 @@ export function NavigationProgressProvider({ }, remainingVisibleMs); }, [setProgressVisible]); - useEffect(() => { - endNavigationProgress(); - }, [pathname, endNavigationProgress]); - useEffect(() => { function handleDocumentClick(event: MouseEvent) { if ( @@ -181,6 +188,9 @@ export function NavigationProgressProvider({ return ( {children} + + +