- Symptom
- A popover opened before navigation is still open on returnuseActionState success messages and input values persist after leaving the pageMount-time logic such as opening a dialog from a query param does not run againE2E tests that relied on a fresh page state start failing
- 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), [])- Affected
- Next.js 16.x with cacheComponents: true
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders