Files
bible/rules/patterns/modal-workflows/drafts/contract.md
T

25 lines
1.5 KiB
Markdown

# Contract: Modal Drafts and Explicit Save
Part of [modal-workflows](../contract.md).
## Explicit Save and Unsaved Changes
- Edit modals persist only on the labeled Save action. Field changes, autofill, child additions,
removals and state toggles remain draft state; no hidden writes on `change` or `blur`.
- Visually mark staged toggles (for example a dashed outline) and explain that Save applies
them. Do not present a draft state as already persisted.
- Track dirty state against a snapshot taken after initial asynchronous loading. Include state
outside inputs, such as pending deletions and toggle maps. Reset the snapshot only after
loading or successful save, never after an unrelated rerender of the edited content.
- Route Escape, backdrop and close buttons through one shared close guard. For dirty forms,
show an in-page choice: Continue editing / Close without saving. Escape on that confirmation
keeps the edits; Escape elsewhere acts on only the topmost modal.
- While submitting, block closing as well as double submission. On failure retain entered
values and show the error inline. If saving requires multiple requests, remember applied
operations so retry does not duplicate them; do not imply that partial success was rolled back.
- Removing a draft child may be staged without an immediate confirmation. Before committing
destructive deletion of persisted data, the separate confirmation required above must still
name the affected records and any cascade. A Save label alone is not that confirmation.
See the [snapshot example](README.md).