UI + UX Error Prevention And Recovery established

Confirmation dialog

Interrupt the requested action with an alert-style decision that names the object, scope, and consequence, makes cancellation safe and easy, and requires an explicit confirming action before commitment.

Decision first

Choose this pattern when the problem matches

Use when

  • The action is destructive, irreversible, costly, security-sensitive, privacy-affecting, or externally visible.
  • Undo or recovery cannot reliably restore the prior state.
  • The dialog can present consequence information the user did not already see at the trigger.
  • A typed or extra-step confirmation is warranted by broad scope or severe impact.

Avoid when

  • The action is routine and easily reversible.
  • The trigger label and surrounding UI already make the low-risk consequence clear.
  • Undo, prevention, preview, or clearer command placement would protect users with less interruption.
  • The dialog only asks users to confirm an action they just clearly selected and adds no new reason to cancel.
  • The action needs editable inputs or a multi-step workflow rather than a yes-or-no consequence decision.

Problem it prevents

Users can accidentally start consequential actions that are costly, security-sensitive, externally visible, or impossible to recover after commitment.

Pattern anatomy

What a strong implementation has to make clear

User need

The user has already invoked an action and the product must verify intent before committing it.

Pattern promise

Interrupt the requested action with an alert-style decision that names the object, scope, and consequence, makes cancellation safe and easy, and requires an explicit confirming action before commitment.

Required state

Pre-action state with an explicit consequential trigger.

Recovery path

Habituation from confirming frequent low-risk actions.

Access contract

Use alertdialog semantics or platform equivalent when the decision is urgent and requires a response.

Quality bar

The difference between expert and weak execution

Strong implementation

Specific, visible, recoverable

  • Delete Research archive? explains that 14 notes and shared links will be permanently removed, offers Keep archive, and labels the danger action Delete archive.
  • A typed DELETE field keeps Delete archive disabled until the user deliberately matches the required text.
  • Cancel, Escape, and Keep archive leave the archive unchanged and return focus to Delete archive.
  • Typing DELETE enables the final action, then the outcome reports that deletion was deliberately confirmed.
Weak implementation

Vague, hidden, hard to recover from

  • A popup says Are you sure? with OK and Cancel but does not name the project, notes, or irreversible outcome.
  • The red destructive action is enabled immediately and sits where users expect the routine primary button.
  • Every archive, filter, and dismiss action opens the same confirmation until users click through automatically.
  • A one-click OK popup deletes the archive without explaining recovery limits or affected shared links.
UI guidance
  • Render an alert-style modal decision with a specific title, consequence description, safe cancellation, and a destructive action label that names the object or scope.
  • Escalate severe broad-scope actions with typed confirmation or another deliberate step before enabling the destructive action.
UX guidance
  • Interrupt users only when the action has a meaningful consequence that cannot be safely recovered afterward.
  • Use confirmation to create an informed decision point, not a reflexive second click after every routine action.
Implementation contract

What the implementation must handle

States

  • Pre-action state with an explicit consequential trigger.
  • Decision state that names the affected object, scope, and irreversible or costly consequence.
  • Safe cancellation state that leaves the object unchanged and returns focus to the trigger.
  • Blocked destructive state before required typed text or safety condition is satisfied.

Interaction

  • The confirmation appears only after a user-initiated action, not as surprise interruption unrelated to the current command.
  • The dialog has alertdialog semantics or equivalent platform behavior when it communicates an urgent decision that requires a response.
  • The title, description, and final action label name what will happen, not just ask Are you sure.
  • The safe path is always reachable by keyboard and pointer before the destructive path is committed.

Accessibility

  • Use alertdialog semantics or platform equivalent when the decision is urgent and requires a response.
  • Provide an accessible name from the visible decision title.
  • Associate the consequence text as the dialog description.
  • Move focus into the dialog when it opens and keep focus within the modal layer.

Review

  • What information in this dialog could reasonably make a user cancel?
  • Can the action be safely undone instead of blocked beforehand?
  • Does the destructive button say exactly what will happen?
  • Is the safe path reachable without interpreting a double negative?
Interactive lab

Inspect the states before you copy the pattern

Confirm a destructive action

Inspect consequence copy, safe cancellation, focus behavior, and the final outcome.

Confirmation dialog
Interactive demo is ready

Launch the live UI/UX lab when you want to inspect states, keyboard behavior, and common failure modes.

State To Inspect

Pre-action state with an explicit consequential trigger.

Keyboard / Access

Enter or Space on the destructive trigger opens the confirmation; it should not commit the final action directly.

Avoid Generating

Asking users to confirm every routine action until they stop reading.

Evidence trail

Source-backed claims behind this guidance

WAI-ARIA APG: Dialog Modal Pattern

W3C Web Accessibility Initiative - checked

Modal dialog guidance supplies the underlying focus containment, Escape, inert background, and focus-return behavior for confirmation dialogs.

Full agent/debug reference

Problem Context

  • The user has already invoked an action and the product must verify intent before committing it.
  • The consequence is destructive, costly, privacy-affecting, security-sensitive, externally visible, or difficult to reverse.
  • A simple undo path cannot reliably restore the prior state after the action completes.
  • The dialog can add information that might reasonably cause the user to cancel.

Selection Rules

  • Choose confirmation when the action has a clear reason not to proceed and the user may change their mind after seeing the consequence.
  • Prefer undo when the exact prior state can be restored reliably after a frequent low-risk action.
  • Prefer prevention when the action is dangerous mainly because it is placed too close to routine controls.
  • Use a typed confirmation or equivalent extra step for broad account, workspace, production-data, or permission deletion.
  • Do not confirm ordinary save, archive, dismiss, filter, navigation, or low-risk edits that users perform repeatedly.
  • Do not use confirmation copy to teach users about a feature; use inline education, preview, or feedback instead.
  • Use a regular modal task when the user needs to edit values, not merely decide whether the consequence should happen.

Required States

  • Pre-action state with an explicit consequential trigger.
  • Decision state that names the affected object, scope, and irreversible or costly consequence.
  • Safe cancellation state that leaves the object unchanged and returns focus to the trigger.
  • Blocked destructive state before required typed text or safety condition is satisfied.
  • Confirmed committing state after the user deliberately activates the destructive action.
  • Outcome state that reports deletion, cancellation, or policy-blocked status.
  • Repeated-action state that avoids prompting for routine reversible actions.

Interaction Contract

  • The confirmation appears only after a user-initiated action, not as surprise interruption unrelated to the current command.
  • The dialog has alertdialog semantics or equivalent platform behavior when it communicates an urgent decision that requires a response.
  • The title, description, and final action label name what will happen, not just ask Are you sure.
  • The safe path is always reachable by keyboard and pointer before the destructive path is committed.
  • Escape cancels when cancellation is safe and follows the same unchanged-object path as the cancel button.
  • The destructive action is disabled or unavailable until any required typed confirmation, checkbox, or acknowledgement is satisfied.
  • Closing after cancel or completion returns focus to the trigger or to the next logical outcome location.
  • The dialog is not repeated for high-frequency actions where users will learn to dismiss it automatically.

Implementation Checklist

  • Name the affected object, count, or scope in the title or main instruction.
  • Explain the consequence once, including whether recovery, audit, billing, permissions, or external recipients are affected.
  • Use a safe cancel label that explains the safe outcome, such as Keep archive or Cancel deletion.
  • Use a destructive action label that contains the verb and object, such as Delete archive.
  • Avoid OK, Yes, No, and Cancel-only button pairs when they force users to reinterpret the question.
  • Keep the safe action reachable by default and avoid committing destruction from an accidental Enter key.
  • Require typed text or a deliberate extra step for severe or broad-scope deletion.
  • Return focus predictably after cancel, Escape, and completion.
  • Track whether frequent prompts are being dismissed unread and replace them with undo or prevention when possible.

Common Generated-UI Mistakes

  • Asking users to confirm every routine action until they stop reading.
  • Using vague Are you sure copy without object, scope, or consequence.
  • Making the destructive action the easiest accidental target.
  • Using confirmation instead of undo for fast reversible actions.
  • Using undo language for irreversible actions that cannot truly be restored.
  • Showing an alert dialog that only educates, advertises, or repeats what the trigger already said.

Critique Questions

  • What information in this dialog could reasonably make a user cancel?
  • Can the action be safely undone instead of blocked beforehand?
  • Does the destructive button say exactly what will happen?
  • Is the safe path reachable without interpreting a double negative?
  • Is the action frequent enough that this prompt will become automatic?
  • Does the dialog name the object, count, permission, cost, recipient, or external system affected?
Accessibility
  • Use alertdialog semantics or platform equivalent when the decision is urgent and requires a response.
  • Provide an accessible name from the visible decision title.
  • Associate the consequence text as the dialog description.
  • Move focus into the dialog when it opens and keep focus within the modal layer.
  • Make the safe cancellation path easy to reach by keyboard.
  • Do not enable the destructive action until typed confirmation or acknowledgement requirements are met.
  • Return focus to the trigger or a clear outcome location after closing.
Keyboard Behavior
  • Enter or Space on the destructive trigger opens the confirmation; it should not commit the final action directly.
  • Initial focus should support safe decision-making, often the typed confirmation field, a non-destructive action, or the explanatory content for severe decisions.
  • Tab and Shift+Tab cycle through the alert dialog controls while it is open.
  • Escape cancels when cancellation is safe.
  • The destructive action remains disabled until required typed text or acknowledgement is valid.
  • After cancel, Escape, or completion, focus returns to the trigger or to the resulting status if the trigger no longer exists.
Variants
  • Delete confirmation
  • Typed deletion confirmation
  • Unsaved-changes confirmation
  • Purchase confirmation
  • Permission escalation confirmation
  • Security-sensitive confirmation
  • Bulk destructive confirmation

Verification

Last verified: