fix: scroll to top after survey slide transition renders

Use requestAnimationFrame to defer scrollTo until after React
renders the new slide content, preventing the browser from
staying at the bottom of the page.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michael Chihlas
2026-03-07 18:22:25 -05:00
parent e6751f6bee
commit 9c7859a889

View File

@@ -188,7 +188,9 @@ export default function SurveyPage() {
const goSlide = (idx: number) => {
setCurrentSlide(idx)
window.scrollTo({ top: 0, behavior: 'smooth' })
requestAnimationFrame(() => {
window.scrollTo({ top: 0, behavior: 'smooth' })
})
}
const handleSubmit = async () => {