From 6f6b93af3149c2f08c29f1fbb27455f0aeaebc62 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Tue, 25 Aug 2026 22:35:52 +0500 Subject: [PATCH] web: restore the scroll position before the editor is painted --- apps/web/src/components/editor/tiptap.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsx index e9d71a3c8..2b3993f0d 100644 --- a/apps/web/src/components/editor/tiptap.tsx +++ b/apps/web/src/components/editor/tiptap.tsx @@ -691,7 +691,10 @@ function TiptapWrapper( theme.scopes.base.primary.paragraph; }, [theme]); - useEffect(() => { + // Runs before the browser paints: `onLoad` restores the scroll position, and + // doing that in a passive effect paints the note at the top for a frame + // before it jumps to where the reader left off. + useLayoutEffect(() => { if (!isHydrating) { onLoad?.(); containerRef.current