Atlas Forms
Cancel Action
The cancel action discards unsaved changes and returns the user to their previous context. It supports a dirty-check — if the form has been modified, a confirmation dialog asks the user whether they really want to discard their work.
Cancel vs Reset
These two actions are often confused. The distinction is intent and navigation:
| Action | What it Does | Stays on Form? | Uses dirty-check? |
|---|---|---|---|
| cancel | Discard changes, navigate away | No — leaves the form | Yes (configurable) |
| reset | Restore all fields to initialValues | Yes — stays on form | No |
Dirty-Check Behaviour
When checkDirty: true (the default), the cancel action checks formEngine.isDirty() before navigating away. If the form is dirty:
- A confirmation dialog appears with your configured message
- If the user confirms: navigation proceeds, draft is discarded
- If the user declines: the dialog closes, the user stays on the form
If the form is not dirty (no changes since last save), the cancel happens immediately with no dialog.
Schema Example
{
"type": "cancel",
"label": "Discard",
"variant": "ghost",
"icon": "times",
"order": 0,
"config": {
"checkDirty": true,
"dirtyWarningMessage": "You have unsaved changes. Are you sure you want to leave?",
"navigateTo": "/dashboard"
}
}
Navigation on Cancel
The navigateTo config field accepts:
- Absolute path:
"/dashboard"— navigates to that route - Relative path:
"../list"— navigates relative to current route - Omitted: calls
window.history.back()— browser back button behaviour
Skipping the Dirty Check
For forms where discarding is always acceptable (read-mostly forms, lookup forms), disable the dirty check:
{
"type": "cancel",
"label": "Close",
"variant": "ghost",
"config": {
"checkDirty": false
}
}
Draft Storage and Cancel
The cancel action discards the in-memory form state but does not automatically clear the
StorageManager draft. If auto-save has been writing the draft, call storage.clearDraft(formId) in your cancel handler if you want to remove the persisted draft too.