Demo 03 · Resume with consent
Manual recovery controls in your application flow
Keep restore and discard actions beside your own headings, consent copy, or step controls. The addon keeps the record private and applies its existing filtering, expiry, cleanup, and status feedback.
Quick facts
- Mode
restoreMode: "manual"- Storage
- Tab-scoped
sessionStoragewith a ten-minute expiry - Generated controls
- None
- Safe result data
- Counts and timestamps only; never stored values
Long service request
Saved-progress controls
Saved progress: Checking availability
Manual-mode recipe
const sessionRecovery = createSessionRecoveryAddon({
formKey: "service-intake",
fieldNames: ["fullName", "email", "request"],
restoreMode: "manual"
});
createFormSubmissionRecovery(form, {
addons: [sessionRecovery]
});
restoreButton.addEventListener("click", () => {
sessionRecovery.restoreAvailable();
});
The real buttons above live outside the form and call controller methods directly. The addon does not require recovery markup in manual mode.
Controller methods
| Method | Result | Use |
|---|---|---|
hasAvailableRecovery() | boolean | Use this to update an application button's disabled state. |
restoreAvailable() | counts plus cleared, or false | Restores the filtered values and uses the existing polite restore message. |
discardAvailable() | { discarded: true } or false | Removes the record and uses the existing polite discard message. |
saveNow() | timestamps/counts, or false | Cancels a pending debounce and stores the filtered current values. |
clear() | { cleared: true } or false | Removes saved progress without an extra recovery announcement. |
Lifecycle and error handling
- Before setup, after
destroy(), when unavailable, or when storage fails, command methods safely returnfalse. - On setup, expired and path-mismatched records are removed. A successful submission still follows
clearOnSuccess. - Listen to the typed session events to refresh external controls after saves, restores, discards, and clears. Event details contain no field values.
- If restoration succeeds but storage cleanup fails, its result has
cleared: false; the existing error event identifies only the failed storage operation.
Accessibility behavior
- These are native buttons in the application's established reading and heading structure.
- Tab reaches each enabled control; Enter and Space activate it through native button behavior.
- Restore and discard use the form's existing polite, atomic status region. No second live region or hidden recovery content is generated.
- Controller commands do not move focus. Disabled state is native
disabled, not color-only feedback.
Privacy boundaries
The addon uses sessionStorage, a versioned key, the
page pathname, a timestamp, expiry, state, and the filtered snapshot.
It handles denied or full storage without breaking the form.
The controller never returns the stored record, a snapshot,
FormData, response content, or saved values. Use a field
allowlist and keep high-risk form storage under dedicated review.
Localization
This demo passes recovery feedback through the addon's
messages option. Your application owns the button names;
the addon uses the localized restore or discard message in the existing
status region. Messages are always inserted as text, not HTML.