AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Scroll-To-Top Lost On Navigation When Root Parallel-Slot Catch-All Sits Next To Sibling Dynamic Segment (Next.Js 16.3+ Optimistic Routing Regression)

In Next.js 16.3.0 and later with optimisticRouting enabled by default, navigation from a dynamic segment to another dynamic route can fail to reset scroll position. This occurs when the app has a root parallel slot with a catch-all page returning null, alongside a sibling dynamic route. Predicted route trees reify stale params, causing a server mismatch and retry that consumes the scroll-ref on an empty catch-all leaf, so the new page retains the previous scroll offset.

highConfidence 92%Next.jsAffected V16.3.0Affected V16.3.1Affected V16.3.2Affected V16.3.3Affected V16.4.0-Canary.10

Origin Analysis

The optimistic routing feature introduced in 16.3.0 predicts known-route trees. When a root parallel slot's catch-all page sits next to a dynamic segment, the predicted tree embeds stale params in the catch-all branch. The server response mismatches, triggering ACTION_SERVER_PATCH with FreshnessPolicy.RefreshAll. During the retry commit, the scrollRef is assigned to the empty catch-all leaf (which renders null and has no client rects), causing its scroll handler to return early without resetting. The actual page leaf runs with ref=null or ref=false, so no segment applies scrollTop=0, leaving the inherited offset.
1. Create app with root layout rendering {children}{modal}. 2. Add app/@modal/default.jsx returning null and app/@modal/[...catchAll]/page.jsx returning null. 3. Add app/page.jsx with a Link to /alice. 4. Add app/[username]/page.jsx with multiple Links to /game/N. 5. Add app/game/[gameId]/page.jsx as a tall dynamic page (force-dynamic optional). 6. Build and start. Navigate to /alice, scroll down, click a game link. The game page opens at the inherited scroll offset instead of top. The issue reproduces in both production and dev, with dev showing alternating failures.

Fixing Code Block

Edge Case Audit

Disabling optimisticRouting turns off the new client-side navigation optimizations introduced in 16.3.0, which may slightly increase perceived navigation latency and alter prefetching behavior. This is intended as a temporary workaround until Next.js ships an upstream fix. To roll back, remove the experimental block and restart. If you implement an additional manual scroll-to-top effect, be cautious of double-scrolling or overriding browser scroll restoration; test both dev and production thoroughly.

Ecosystem Topology