Onboarding Checklist and the Browser Back Button
A step that opens a sub-view and gets marked complete on mount will also get marked complete when the user hits back mid-way through. Here is how to keep step state honest against browser navigation.
Most onboarding steps assume a straight line: the user clicks a step, is taken somewhere (a settings panel, a modal, a separate route), does the thing, and is routed back to the checklist with the step marked done. The browser back button breaks that assumption without breaking anything your tests would catch. A user clicks a step, the app navigates to /settings/calendar, and before they finish connecting anything they hit back. If completion was wired to the navigation event rather than the action it was supposed to represent, the step is now marked done and nobody connected a calendar.
This is not a hypothetical edge case; it is the default behavior of several common implementation patterns, and it tends to survive code review because the demo path never involves a user who changes their mind.
The pattern that causes it
The usual trigger is marking a step complete in a useEffect or route-mount handler for the destination page, on the theory that reaching the page proves the user started the task, and a second effect on unmount (or a beacon on page leave) will catch anyone who didn't finish. In practice the unmount handler is the one that gets skipped — back-button navigation in most SPA routers fires differently than a normal link click, and a handler that works when the user clicks a \"done\" button inside the sub-view does not fire at all when they leave via back, forward, or closing the tab. The step gets marked complete on arrival and nothing ever un-marks it.
A second version of the same bug shows up with multi-field forms split across several screens inside one step. The step is marked complete when the user reaches the final screen, but back-button navigation lets them return to an earlier screen, change an answer, and leave from there — at which point the checklist already thinks the step is done, and the server-side record that should back it up (see the note on retrying a step safely) was never actually written.
Tie completion to the action, not the route
The fix is to stop treating page arrival as evidence of anything. Completion should fire from the same place that performs the underlying action — the API call that actually connects the calendar, saves the field, or creates the resource — and nowhere else. If that call succeeds, mark the step done from the success handler of the call itself, synchronously with the write, not from a route effect that merely observes the user is on the right page.
Concretely: a step labeled \"connect your calendar\" should transition to complete inside the callback that receives a successful OAuth exchange or API confirmation, not inside the component that renders the connect button. That way, back-button navigation before the exchange succeeds leaves the step untouched, and reaching the same screen twice (because the user came back and finished it the second time) does not require any special-case logic — the completion call fires exactly once, when the thing it represents actually happened.
What to do about state the user already changed
Back navigation inside a multi-screen step also raises a smaller question: if the user goes back and edits an earlier field, should the step's in-progress draft update too? Treat draft state and completion state as two different writes. Persist draft answers on every field change (debounced, not on every keystroke) keyed to the step id, independent of whether the step is later marked complete. That way, back-and-forth navigation inside an unfinished step never costs the user their partial input, and completion still only fires once, from the one place that performs the final action.
Testing for it
This bug is specifically invisible to a test suite that only drives forward navigation, so the test has to include the back button explicitly: start a step, navigate into its sub-view, trigger the browser's back action (not a cancel button, not a route change triggered by the app — the actual history-back event) before the underlying action completes, and assert the step is still incomplete. Repeat with forward navigation after a back, and with closing and reopening the tab mid-step. If any of those leave the step marked complete, the completion call is still wired to arrival rather than to the action.
What to measure instead of guessing
There's no general number for how often users hit back mid-step — it depends entirely on how many screens a given step spans and how obvious the forward path is. What you can measure directly is the gap between steps marked complete and the underlying resource actually existing: for any step tied to creating or changing something server-side, periodically reconcile the step-completion table against the resource it claims to represent (a calendar connection row, a saved preference) and treat a mismatch as a bug report, not a user-behavior statistic. That reconciliation count, tracked over time, tells you whether this class of bug is present at all — no benchmark needed.
If you're deciding where in the stack to make this fix, the step completion API is the right layer: it's the one place every client, regardless of router or framework, ends up calling when a step genuinely finishes. See restoring checklist state after a client crash for the closely related problem of a tab that disappears entirely mid-step, and open the checklist in preview to see how the current step record separates draft state from completion.