diff --git a/src/components/Layout/useTocHighlight.tsx b/src/components/Layout/useTocHighlight.tsx index 02385409ff6..819e652d589 100644 --- a/src/components/Layout/useTocHighlight.tsx +++ b/src/components/Layout/useTocHighlight.tsx @@ -69,7 +69,7 @@ export function useTocHighlight() { } document.addEventListener('scroll', throttledUpdateActiveLink); - document.addEventListener('resize', throttledUpdateActiveLink); + window.addEventListener('resize', throttledUpdateActiveLink); updateActiveLink(); @@ -79,7 +79,7 @@ export function useTocHighlight() { timeoutRef.current = null; } document.removeEventListener('scroll', throttledUpdateActiveLink); - document.removeEventListener('resize', throttledUpdateActiveLink); + window.removeEventListener('resize', throttledUpdateActiveLink); }; }, []);