Undo
Undo lets a person take back an action right after doing it, usually from a button in the message that confirms it. For changes that can be reversed it is kinder than a confirmation dialog, because it costs nothing when the action was right. Meadowstack offers undo in the toast after reversible changes and keeps confirmation for the steps that cannot be put back.
By Bohuslav PoláčekChecked
// A toast stays clickable while a dialog or side panel is open: Radix turns
// pointer events off on the body under a modal, which made "Vrátit" dead and
// the panels close themselves before showing an undo (17 Oct 2026). The
// dialogs in turn ignore a click on a toast (overlays.tsx).
/**
* The app's toasts, mounted once; toast() shows one.
* @when A passing confirmation after an action, with "Vrátit" when it can be undone.
* @not For something that needs attention (Notice); For a decision (Dialog)
* @replaces a hand-built snackbar; alert(); sonner imported in the appWhy it matters in a business app
A team lead changes a colleague's role and picks the wrong one. A dispatcher archives the wrong notification. With a confirmation dialog before every such change, people learn to click "Yes" without reading, and the dialog stops protecting anything. With undo, the change happens at once and the mistake costs one click.
Undo needs two things to be honest: the change must really be reversible on the server, and the history must show both steps.
How Meadowstack handles it
- The rule. AGENTS.md: every screen people use daily has its actions complete, including "undo or a confirm". Deletes go through
ConfirmButton, irreversible actions throughuseConfirm. - Undo in the toast.
toast()from the kit'sToastertakes an action; the starter's Team and roles page offers "Undo" after a role change and sends the old role back through the same api. - Notifications. The bell's
NotificationCenterarchives with undo. - No race. Undo is a second change of the same record, often sent before the first one's answer arrives.
useTurnslets only the newest answer write to the screen, andsetData((current) => …)builds on the data as it is now (optimistic UI). - Clickable over a panel. A toast stays clickable while a dialog or side panel is open, and dialogs ignore clicks on toasts.
- On the record. Every state change writes an audit entry, so the change and its undo both show in
AuditTimeline.
Common mistakes
- Undo that only changes the screen. The server keeps the first change and the record jumps back on reload.
- Undo for what cannot be undone. A sent email or a payment cannot be called back; confirm first and say so.
- A toast that vanishes in two seconds. Give people time to read it and reach the button.
The newest answer wins
* useTurns: the newest answer wins. A change shows on screen at once and the
* server answers later, so two changes of one record can overlap (a double
* click, "Undo" right after an approval, any slow network). Each change takes
* a turn when it starts, and only the holder of the latest turn may write its
* answer onto the screen; otherwise the first answer lands after the second
* change was shown and steps the record back. Records are told apart by id.
*/
import { useRef } from "react";
export function useTurns() {
const turns = useRef(new Map<string, number>());
/** Starts a change of one record; the function it returns says whether that change is still the newest. */
return (id: string) => {
const turn = (turns.current.get(id) ?? 0) + 1;
turns.current.set(id, turn);
return () => turns.current.get(id) === turn;Questions
Is undo better than a confirmation dialog?
For reversible changes, usually yes: it does not slow down the person who was right. For irreversible ones, such as sending or deleting for good, a confirmation that names what will happen is the honest choice.
How long should undo stay available?
Long enough to notice the mistake and reach the button. After that the change can still be reversed by hand from the record, because its history shows what it was.
Does undo need a server endpoint of its own?
Not necessarily. In Meadowstack's starter, undoing a role change sends the previous role through the same call that made the change.
Related
- A document inbox that catches a changed bank accountScreens
- A proof the customer approves in their own portalScreens
- A time-off request waiting for a decisionScreens
- An order record with its decisionScreens
- ApprovalPanel: the decision card on a recordComponents
- AuditTimeline: a record's history and commentsComponents
Two ways
Build it yourself, or have it built
Build it yourself
Build your app on the framework
Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.
One payment, lifetime updates
Get the frameworkHave it built
Have us build your app
Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.
After launch, Care keeps it improving, from €99 a month.
from €1,990
Describe your app