feat(escrow): persist wizard draft state and add step navigation guar… - #615
Closed
datagerl wants to merge 3 commits into
Closed
feat(escrow): persist wizard draft state and add step navigation guar…#615datagerl wants to merge 3 commits into
datagerl wants to merge 3 commits into
Conversation
…ds Wire up localStorage draft persistence for the 7-step CreateEscrowWizard so in-progress escrows survive refreshes, accidental navigation, and the browser back button. - Auto-save wizard state to localStorage, debounced 1s, on every step/field change - Restore drafts on mount via a "Resume draft?" prompt; clear drafts older than 7 days - Clear the saved draft on successful escrow creation - Sync the current step to a ?step= URL query param for bookmarkability - Handle popstate so the browser back button moves through wizard steps instead of leaving the page - Warn via beforeunload when closing the tab with unsaved changes - Add a Cancel action in the wizard header, wired to the existing "Discard draft?" confirmation, so navigating away mid-wizard is guarded - Add a manual "Save draft" button alongside Next/Submit Add unit tests for useWizardDraft (save/restore/expiry/corrupted data) and for CreateEscrowWizard (step navigation, autosave, resume/discard, cancel flow). Update the existing wizard test file, which predated the template-selector step and was not runnable (missing ToastProvider). Closes: draft persistence for CreateEscrowWizard
|
@datagerl Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…S[currentStep].fields to Path<CreateEscrowFormData>[] instead of string[] so it satisfies trigger()'s expected field path union, fixing a build-blocking type error in CreateEscrowWizard.tsx.
Contributor
|
@datagerl kindly fix CI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The CreateEscrowWizard (7-step form) previously lost all entered data on
page refresh, accidental navigation, or the browser back button — there
was no draft persistence, no popstate handling, and no beforeunload
warning. Users filling out milestones, conditions, and parties could
lose several minutes of work on any interruption.
This PR completes draft persistence and step-navigation guards for the
wizard.
Changes Made
useWizardDrafthook: debounced (1s) localStorage autosave, draftrestore with 7-day expiry, manual save, clear/discard
CreateEscrowWizard:?step=for bookmarkable/shareable URLspopstateso the browser back button steps backward throughthe wizard instead of navigating away
beforeunloadwhen there are unsaved changes past step 1"Discard draft?" confirmation modal (previously unused/dead code) —
this is now the actual trigger for that criterion
Testing Done
apps/frontend/hooks/useWizardDraft.test.ts— 9 new tests (save,debounce timing/reset, restore, 7-day expiry boundary, corrupted JSON,
clear/discard)
apps/frontend/components/escrow/CreateEscrowWizard.test.tsx— 15tests (step validation, URL step sync, back-button navigation,
autosave + indicator, manual save, beforeunload warning,
resume/discard prompts, expired-draft cleanup, cancel/discard flow).
This file previously could not run at all (missing
ToastProvider,written before the template-selector step existed) — rewritten to
match current component behavior.
pnpm test. The onlyfailures are 7 pre-existing suites unrelated to this change (wallet
modal, escrow events/list hooks, transaction tracker — all
network/MSW related), not touched here.
Acceptance Criteria
Out of Scope
Several other test suites in
apps/frontendwere already failing beforethis change (network-dependent hook/wallet tests) — left untouched as
unrelated pre-existing issues.
Checklist
closes #603