From 316951c2bf6e7e8372afad668da62e4f50bfc3aa Mon Sep 17 00:00:00 2001 From: kashaf-ansari-dev Date: Tue, 11 Aug 2026 09:36:50 +0500 Subject: [PATCH] editor: guard scroll persistence until note session is restored Signed-off-by: kashaf-ansari-dev --- packages/editor-mobile/src/hooks/useEditorController.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/editor-mobile/src/hooks/useEditorController.ts b/packages/editor-mobile/src/hooks/useEditorController.ts index e5b9a2ceb..33c4fc474 100644 --- a/packages/editor-mobile/src/hooks/useEditorController.ts +++ b/packages/editor-mobile/src/hooks/useEditorController.ts @@ -139,6 +139,7 @@ export function useEditorController({ wordCounter: null, scroll: null }); + const hasRestored = useRef(false); if (!tabRef.current.session?.noteId && loading) { setTimeout(() => { @@ -300,6 +301,7 @@ export function useEditorController({ const scroll = useCallback( (_event: React.UIEvent) => { + if (!hasRestored.current) return; const value = _event.currentTarget.scrollTop; if (timers.current.scroll !== null) clearTimeout(timers.current.scroll); timers.current.scroll = setTimeout(() => { @@ -367,6 +369,7 @@ export function useEditorController({ } scrollTo?.(value.scrollTop || 0); + hasRestored.current = true; setLoading(false); countWords(0); } @@ -382,6 +385,7 @@ export function useEditorController({ logger("info", "LOADING NOTE HTML"); if (!editor) break; update(value.scrollTop, value.selection, value.searchResultIndex); + hasRestored.current = true; setTimeout(() => { countWords(0); }, 300);