Next.js · sdk · fg-0311

With cacheComponents, dropdowns stay open and forms keep old values after navigating away and back

If you see A popover opened before navigation is still open on return, the cause and the fix for Next.js are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
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

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun