repl: defer scrollTo via rAF so first-render restored transcript lands at bottom

This commit is contained in:
russell@unturf.com 2026-06-14 15:47:23 -04:00
parent 07033cd96f
commit e2ebefe0f9
No known key found for this signature in database
2 changed files with 14 additions and 4 deletions

View file

@ -287,8 +287,13 @@ function renderAll() {
}
transcriptEl.appendChild(block);
}
// Body owns the scroll now; jump it to the latest entry.
window.scrollTo({ top: document.documentElement.scrollHeight, behavior: "instant" });
// Body owns the scroll now; jump to the bottom after layout settles.
// requestAnimationFrame lets the just-mounted DOM contribute to
// scrollHeight before we measure — otherwise on first load the page
// sticks at the top because the transcript hasn't been laid out yet.
requestAnimationFrame(() => {
window.scrollTo({ top: document.documentElement.scrollHeight, behavior: "instant" });
});
}
// ─── Input handling ─────────────────────────────────────────────────

View file

@ -287,8 +287,13 @@ function renderAll() {
}
transcriptEl.appendChild(block);
}
// Body owns the scroll now; jump it to the latest entry.
window.scrollTo({ top: document.documentElement.scrollHeight, behavior: "instant" });
// Body owns the scroll now; jump to the bottom after layout settles.
// requestAnimationFrame lets the just-mounted DOM contribute to
// scrollHeight before we measure — otherwise on first load the page
// sticks at the top because the transcript hasn't been laid out yet.
requestAnimationFrame(() => {
window.scrollTo({ top: document.documentElement.scrollHeight, behavior: "instant" });
});
}
// ─── Input handling ─────────────────────────────────────────────────