All articles

Web engineering

Keep a form’s recovery state separate from its submission state

When someone returns to a business form, the interface should explain whether their draft survived and whether the business operation was accepted. Those answers need separate evidence. A visible field, a recovered page and a completed server-side operation can each tell a different story.

KIURO Editorial · Published: · Reviewed:

This is an evergreen engineering guide, not a newly launched browser feature. MDN documents visibilitychange and visibilityState for observing a page becoming hidden. Its usage notes identify that transition as an important lifecycle point; the event itself is not confirmation that application data was saved or an operation was submitted. (MDN Web Docs)

Define what the form is allowed to retain

Begin with the product’s promise. A temporary calculation, a personal enquiry draft and a shared operational record may require different handling. Decide which fields can persist, where they may persist, who can recover them and how they are cleared. A form that promises not to retain notes should not quietly acquire persistent drafts during a reliability improvement.

Separate the choices into interface state, an authorised draft and the submitted record. Interface state includes the current step or an expanded panel. A draft may contain unfinished business information. The submitted record represents an operation the application must recognise independently of the page that initiated it. These distinctions should be visible in acceptance criteria before storage is added.

Proposed user-facing state vocabulary; adapt it to the application’s real guarantees.
StateWhat the interface may truthfully sayEvidence it needs
Unsaved draftYour changes are currently in this formCurrent local interface state
Persisted draftDraft saved in the stated placeCompletion of the chosen draft-write operation
Submission in progressSending; outcome not yet confirmedAn operation has started, without a conclusive result
Submission acceptedAccepted, with the available referenceServer-side acceptance evidence
Outcome uncertainWe could not confirm the resultA reconciliation path before another attempt

Treat returning to the page as a path worth testing

Chrome’s lifecycle guide explains that a hidden page can later be frozen, terminated or discarded, with no reliable final callback in every case. A save attempted only during page termination can therefore miss important paths. Lifecycle events and browser support need to be considered individually. (Chrome for Developers / Philip Walton)

Design saving around the period when the page can still do useful work, and show a saved indication only after the selected write has completed. If saving requires a server, define how the page behaves while offline or while that server is unavailable. If it uses permitted local storage, define what happens on a shared device, after sign-out and when the retention period ends.

Do not turn an unfinished write into a success message simply because the user switched tabs. A lifecycle signal can start an application action; your application still needs evidence of that action’s outcome. The same care applies when a user returns and sees a value already present in a field.

Back navigation can restore memory rather than reload the form

The back/forward cache can restore a page and its JavaScript state from memory. The documented pageshow event exposes persisted to identify a restoration. A pagehide event indicating intended caching does not guarantee restoration later, and freeze/resume coverage differs from those navigation events. (web.dev / Chrome team)

For a business form, restoration raises a freshness question as well as a recovery question. A previously displayed customer, inventory quantity or permission may have changed elsewhere. Decide which restored values are still draft input and which must be refreshed or confirmed before the next business action. Keep the user’s authorised unsent work separate from information that the server now considers outdated.

Use a matrix that tests the actual operation

The following is a proposed test matrix using fictional records. It was not executed for this article. For each case, record the browser and version, device, storage policy, initial state and the evidence observed after returning.

Proposed test matrix for draft recovery and submission status across browser lifecycle changes.
CaseDraft questionBusiness-operation question
Background tab, then returnAre the permitted fields and current step preserved?Was any operation wrongly treated as submitted?
Switch to another mobile appWhat remains after a short and a longer absence?Does the displayed status still match the known outcome?
Navigate away, then BackWas the page restored or loaded again?Are stale server-derived values checked before use?
Reload or discard/reloadCan the permitted draft be recovered from its stated location?Can the previous submission be looked up independently?
Interrupt a submissionDoes the unsent work remain understandable?Can an uncertain outcome be reconciled before retry?
Sign out, then returnAre restricted drafts cleared or withheld as designed?Is the recovered interface consistent with current access?

Record both the expected result and what would count as failure. “The form still looks right” is too weak if the page has silently repeated a business operation, lost a required attachment or displayed another user’s draft. Include accessibility in the inspection: status changes need to be understandable through the form’s supported input and reading methods.

Recovery should give the user a clear next action

After an uncertain submission, help the user check whether the operation exists before asking them to repeat it. The exact reconciliation mechanism depends on the application: it might be an operation reference, a record lookup or assistance from the responsible team. Avoid assigning “sent” based only on local memory or restoring the submit button without accounting for the earlier attempt.

Choose one important form and agree its retention and recovery contract first. Browser behaviour should be tested on the devices the audience actually uses. Development, storage and maintenance effort remain application-specific; this guide changes no existing form, storage policy or cache header. For an implementation project, the web application scope should include these recovery paths alongside the successful submission path.

Sources

Privacy & analytics

With your permission, Kiuro uses Google Analytics 4 to understand page visits and interactions such as navigation between pages, reading depth, project views, contact-link clicks and starting or successfully submitting a form. Google also processes browser, device and approximate location information. The provider is Google Ireland Limited (Ireland); processing may also take place at Google LLC in the United States.

We do not send your name, email address or message content. Advertising storage, advertising personalisation and Google signals are disabled. Google Analytics is not loaded before you allow it.

After consent, a temporary record in this tab is valid for 30 seconds and consumed when the next page loads. Your choice is saved on this browser for six months. Analytics cookies are configured to expire after six months. You can change your choice here at any time; rejecting stops measurement and removes this website’s Analytics cookies.

Your light/dark and motion preferences are stored separately on this device so the interface remembers your choices. Contact: hello@kiuro.ch.