web: restore the scroll position before the editor is painted

This commit is contained in:
Ammar Ahmed
2026-08-25 22:35:52 +05:00
parent 872987de0b
commit 6f6b93af31

View File

@@ -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