Skip to content

Dashboard: show new forms after Back without a reload - #14

Merged
shatheitguy merged 1 commit into
mainfrom
dashboard-back-refresh
Nov 19, 2026
Merged

shatheitguy merged 1 commit into
mainfrom
dashboard-back-refresh

Conversation

@shatheitguy

Copy link
Copy Markdown
Owner

What changed

components/nav-progress.tsx (already on every page) now listens for popstate and calls router.refresh() right after Next.js has handled it.

Why

#13 set staleTimes.dynamic = 0, which fixed link clicks, but Next.js 14 always restores Back/Forward from its client router cache. Creating a form from the dashboard and then pressing Back (browser or the Android app's back button) showed the dashboard from before the form existed until a full reload.

The refresh is queued with setTimeout(…, 0): when the cached tree is available, Next.js renders the restored page synchronously inside the same popstate event, so a flag read in an effect was too late.

Testing

  • tsc --noEmit passes.
  • Dev server: fresh page load → create form → builder → history.back(). Before: dashboard showed 4 forms, the new one missing. After: the new form appears within ~250 ms. Link-click path unchanged.
  • Test forms and Trash entries created during testing were removed.

Next.js restores its saved copy of a page on Back/Forward (browser, or the
phone's back button in the app), from before any change: a form created in
the builder was missing from the dashboard until a reload. Now every
Back/Forward shows the saved page instantly and then fetches the fresh one.
The refresh is queued after Next.js handles the same popstate, because it
can show the saved page synchronously.
@shatheitguy
shatheitguy merged commit 84782d6 into main Nov 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant