- **A queued scroll event overwrites the saved scroll when Back follows a visit within one frame (root-caused 2026-11-13, issue #404).** A Turbo visit scrolls the new page to the top at render, which queues a scroll event for the next frame. `popstate` from a Back in that frame switches `history.restorationIdentifier` to the previous entry first, so `ScrollObserver` records the new page's `{y: 0}` on the *previous* entry, replacing the saved position; the restore visit then reads 0 (`spec/system/menu_tab_bar_clearance_spec.rb`, AC-1.13, `expected 0 to be within 1 of 442.75`, 3 in 60 runs). It isn't the restore reading early, and `wait_for_turbo_idle`'s `aria-busy` check can't see it (cleared at `turbo:load`). Not reachable by a person (the window is one frame, ~16 ms) and no app code is involved. A deterministic reproducer calls `history.back()` from a `turbo:load` handler (7 of 8 runs failed); its code is in the issue. The fix is `wait_for_scroll_events` (`spec/support/turbo_idle.rb`, two animation frames, no sleep), which `wait_for_turbo_idle` now calls. To find it: log `turbo:visit`, `turbo:before-render`, `turbo:render`, `turbo:load`, `scroll` and `popstate` in the frame with `scrollY`, `busy` and `history.restorationData` of the current identifier.
0 commit comments