DocsFeedback & undo
Get started

Search Subtly documentation

Search by a task, helper name or framework.

Feedback & undo

undoAction()

Let someone undo a recent change.

Try the example

Archive the sample task. It disappears immediately and you have five seconds to undo. The final commit here only updates this local demo.

Review the landing pageDesign · Today
To do

One task in your list.

Actual npm package · local demonstration

Add it to your project

  1. Copy the HTML. Place the markup inside the component where this behavior belongs. The preview’s visual classes are website styles; use your own design system.
  2. Connect the behavior. Copy the JavaScript tab and call its exported mount(element) after your component’s elements exist. Replace simulated delays and data operations with your own application code.
  3. Clean up. Call the returned cleanup when the component unmounts. It aborts the example’s listeners and releases the helper’s timers, observers or state.

API and lifecycle

Provide apply(), revert(), commit() and an optional duration, defaulting to 5 seconds. start() applies a local preview and starts the undo window. The permanent commit runs after the deadline.

Interface
apply/revert/commit/duration; start/undo/finish/destroy
Lifecycle
undo() reverts while pending; finish() commits early. destroy() cancels a pending action and reverts its preview. Handle commit errors so the user can recover.

Accessibility and safety

Implementation notes

Use for reversible low-risk actions; do not rely on page-exit timers for critical writes.

Use for reversible, low-risk changes and keep Undo keyboard accessible. Do not rely on a page-exit timer to complete a critical permanent write.

What to check

Remove an item, undo before the deadline, then repeat and let it commit. Test commit rejection and unmounting during the undo window.