fix: cancel onboarding enter frames (#3418)

This commit is contained in:
Neil
2026-05-29 19:16:47 -07:00
committed by GitHub
parent a6f7a6cb61
commit c6c05d2a5d
@@ -82,7 +82,7 @@ export function OnboardingInlineCommandTerminal({
useEffect(() => {
if (!autoScrollIntoView) {
return
return undefined
}
if (prefersReducedMotion) {
const scrollFrame = window.requestAnimationFrame(() => {
@@ -93,20 +93,32 @@ export function OnboardingInlineCommandTerminal({
// Why: double rAF guarantees the browser commits the initial collapsed
// styles before we flip to `entered`, so the height/opacity transition
// actually plays instead of snapping straight to the final state.
let enteredFrame: number | null = null
const enterFrame = window.requestAnimationFrame(() => {
window.requestAnimationFrame(() => setEntered(true))
enteredFrame = window.requestAnimationFrame(() => setEntered(true))
})
return () => window.cancelAnimationFrame(enterFrame)
return () => {
window.cancelAnimationFrame(enterFrame)
if (enteredFrame !== null) {
window.cancelAnimationFrame(enteredFrame)
}
}
}, [autoScrollIntoView, prefersReducedMotion])
useEffect(() => {
if (autoScrollIntoView) {
return
return undefined
}
let enteredFrame: number | null = null
const enterFrame = window.requestAnimationFrame(() => {
window.requestAnimationFrame(() => setEntered(true))
enteredFrame = window.requestAnimationFrame(() => setEntered(true))
})
return () => window.cancelAnimationFrame(enterFrame)
return () => {
window.cancelAnimationFrame(enterFrame)
if (enteredFrame !== null) {
window.cancelAnimationFrame(enteredFrame)
}
}
}, [autoScrollIntoView])
// Why: tracking scroll *during* the height transition is unavoidably