From 139a227aa4e152f28d388f500b5d0f259d904fea Mon Sep 17 00:00:00 2001 From: Richard R Date: Wed, 27 May 2026 16:12:09 -0600 Subject: [PATCH] fix(html): use ref to ensure latest clearCurrDoc on unmount --- src/app/(app)/html/[id]/page.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/(app)/html/[id]/page.tsx b/src/app/(app)/html/[id]/page.tsx index 76f6d11..4272c3b 100644 --- a/src/app/(app)/html/[id]/page.tsx +++ b/src/app/(app)/html/[id]/page.tsx @@ -46,6 +46,7 @@ export default function HTMLPage() { const [maxPadPx, setMaxPadPx] = useState(0); const inFlightDocIdRef = useRef(null); const loadedDocIdRef = useRef(null); + const clearCurrDocRef = useRef(clearCurrDoc); useEffect(() => { setIsLoading(true); @@ -103,11 +104,15 @@ export default function HTMLPage() { }, [loadDocument, isLoading]); useEffect(() => { - return () => { - clearCurrDoc(); - }; + clearCurrDocRef.current = clearCurrDoc; }, [clearCurrDoc]); + useEffect(() => { + return () => { + clearCurrDocRef.current(); + }; + }, []); + // Compute available height = viewport - (header height + tts bar height) useEffect(() => { const compute = () => {