Next.js · sdk · fg-0311
With cacheComponents, dropdowns stay open and forms keep old values after navigating away and back
A popover opened before navigation is still open on return
Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100
Cause
With cacheComponents, the router keeps visited routes in a hidden React Activity instead of unmounting them. useState, form inputs and scroll survive the round trip.
Fix
Add explicit resets: close popovers in a useLayoutEffect cleanup, derive dialog open state from the URL, and reset forms in the submit handler.
Apply
useLayoutEffect(() => () => setOpen(false), [])
Affects: Next.js 16.x with cacheComponents: true
Sources
- https://nextjs.org/docs/app/guides/migrating-to-cache-components
- https://nextjs.org/docs/app/guides/preserving-ui-state
- https://github.com/vercel/next.js/issues/86577
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp