Search topics
Toasts that vanish before you can read or undo them
A "Message deleted" toast holds the only Undo and removes itself after four seconds, so anyone slower to reach it loses the action.
setTimeout(…, 4000) The problem
People who read, move or find things more slowly lose the only way to undo a deletion, because the toast that holds it removes itself after four seconds
An inbox lists messages, each with a Delete button. Press Delete and the row goes; a dark toast appears in the bottom corner: "Message deleted. Undo". Four seconds later it slides away, and the message is gone for good. There is no Trash. A sighted mouse user who deleted the wrong message sees the toast and clicks Undo in time. Everyone else has to be fast.
The toast is even announced. It is added inside a role="status" container that is always on the page, so a screen reader says "Message deleted, Undo". The failure is not that it is silent: it is that it doesn't wait.
Success Criterion 2.2.1 Timing Adjustable covers any time limit the content sets, and anything that changes or disappears on its own after a set time is one. W3C's Understanding document uses this very case: a mail notification that disappears after five seconds is not a problem when the same information can be found another way, such as by looking in the inbox, but if people have no other way to get it, the timed message must meet the criterion. Here the toast holds the only Undo. To pass, people would need to be able to turn the limit off, or adjust it to at least ten times the default, before meeting it, or be warned and given at least 20 seconds to extend it with a simple action, at least ten times. None of that exists, so the action has a four-second deadline.
The toast is announced correctly, so the timer is the whole failure. An announcement doesn't help if the thing announced has gone before anyone can act on it.
How long four seconds is depends on how people use the page. Reading the message, deciding it was a mistake and getting to the button all take time, and the people who need more of it are the ones least likely to see the toast at all. On a phone, the toast often covers the bottom of the list as well, so people may wait for it to leave before carrying on.
4 of 10 groups affected
- No vision (affected)
- Low vision (affected)
- Colour vision (not affected)
- No hearing (not affected)
- Hard of hearing (not affected)
- No speech (not affected)
- Motor (affected)
- Reach, strength (not affected)
- Cognitive (affected)
- Seizures (not affected)
- Without vision Screen reader users hear "Message deleted, Undo", but by the time they have moved to the toast to use it, it is gone, and nothing tells them it went.
- Limited manipulation Keyboard and switch users have to Tab past the rest of the list to reach the toast after it, and four seconds is rarely enough.
- Limited vision Screen magnifier users zoomed in on the list don't see a toast in the corner, and it has gone before they could pan to it.
- Limited language, cognitive and learning abilities People who need longer to read, or to decide whether they meant to delete, lose the choice while still reading the message.
A scan sees a role="status" container, a button with a name and good contrast, and passes all of it; timers live in script, and the toast is usually gone before any tool looks. A scan of a page with no toast showing finds nothing at all. AI assistants and component libraries default to toasts that close after a few seconds, often with Undo inside, because that is how the pattern is usually drawn. Some add "pause on hover", which helps only the mouse users who were already fast enough. Only a person deleting something and taking their time, with a keyboard, a screen reader or a magnifier, shows the failure.
Try it
Delete a message, then try to undo it
Use Tab and Enter, and take your time. Can you still reach Undo?
Broken Can you fix this?
- Lunch on Friday
- Invoice for March
- Team photos
- Weekly report
The fix
Don't let a timer take away an action people need
<ul id="inbox"> <li>Lunch on Friday <button type="button" class="delete">Delete</button></li> <!-- … --></ul><div id="toasts" class="toasts" role="status"></div>What is wrong3 points
- After four seconds the deleted message can't be got back: the only way is the Undo inside the toast, and the toast removes itself after four seconds.
- People who can't hurry have no way out: nothing lets them turn the four seconds off, make them at least ten times longer, or be warned and given at least 20 seconds to extend them, as 2.2.1 asks.
- For anyone who reads, moves or finds the toast more slowly, the Undo has already gone.
A toast that stays until it is closed
<ul id="inbox"> <li>Lunch on Friday <button type="button" class="delete">Delete</button></li> <!-- … --></ul><!-- Straight after the list, so Tab reaches it soon --><div id="toasts" class="toasts" role="status"></div>How it is fixed4 steps
- Drop the
setTimeout. The toast keeps its look and its announcement, but no timer removes it. - Add a Close button beside Undo, so it goes when the person presses Undo or Close.
- Show it with
replaceChildren(), so the next toast replaces it. - Put the toast container straight after the content it reports on, not at the end of the page: keyboard users reach it by Tab.
This fixes the Before and passes 2.2.1: people can take as long as they need to read it, Tab to it and decide. Keep the toast from covering the list while it stays.
Why this fix: Change the page only when people ask
Both pass 2.2.1, and both keep the message announced. Which suits depends on where the delete happens. For one row in a list that stays put, put the Undo where the item was: focus is already on it, nothing floats over the page, and no one has to Tab to find it. Where there is no such place, as with bulk deletes, re-sorting or paged lists, or a delete from the item's own page, use the toast that stays until closed; it is also the quickest change for a site that already shows its messages as toasts. Many sites will use both.
Pausing on hover or focus is not enough on its own. It stops the timer once someone reaches the toast, which helps only the people who reached it in time. Do it anyway in a toast that still has a timer: nothing should disappear while a pointer is on it or focus is inside it.
A Trash can let a toast time out. If the site already keeps deleted items in a Trash with Restore, a toast that closes by itself passes 2.2.1, because the same function can be performed another way, which the Understanding page for 2.2.1 allows (its own example is a timed new-mail notice whose mail is also in the inbox). The toast must say where the item went ("Moved to Trash"), and its timer should stop once a pointer or focus reaches it. People who miss it still take several steps to restore what one button would have done, so don't build a Trash only to keep a timer.
A setting can pass, if people find it. 2.2.1 also accepts a way to turn the limit off, or to lengthen it at least tenfold, before people meet it, such as "Keep notifications until I close them" in the account settings. Most people never see that setting, so it suits a site that keeps timed toasts for other reasons, not as the main fix.
A toast with nothing to act on. "Settings saved" holds no action, and if the saved state is visible on the page, its disappearing does not take anything away. Give it time to be read anyway, and put anything people must act on, such as a failure, somewhere it stays.
When the delete really happens. Undo in place and the lasting toast both hold a delete open. Commit it on the person's next action or when they leave, not on a timer, and keep the server state honest: either send the delete at once and undo it with a restore call, or send it when it is committed. If people can lose work by closing the tab, the first is safer.
Where focus goes. When the pressed control disappears, focus must move; left alone it falls to the page body and keyboard users start again from the top. Moving focus to an Undo that replaced the row is expected. Moving focus to a toast at the edge of the page, in the middle of other work, is not: keep that for a message that the person must answer.
Many toasts. A stack of lasting toasts covers the page. Replace the previous toast with the next one, as the lasting toast does, or cap the stack and offer "Close all".
Not a fix. role="alert" or aria-live="assertive" gets the toast read sooner, but the time to act stays the same, and it interrupts whatever the screen reader was saying. A longer timer, such as ten seconds, is still a fixed limit that someone will miss.
Design ideas
Keep the Undo for as long as people need it
Three ways to say a message was deleted, each drawn just after a delete in the inbox. The two with a timer start their four seconds when they scroll into view, and Start again sets one back; point at the messages, Tab into them and delete the other message.
In the design file
- Draw the message with a Close button next to Undo, placed where it covers nothing in the list.
- Undo in place: the deleted row replaced by a short message and an Undo button, with the focus ring on Undo.
- Let a message disappear on its own only if deleted items go to a Trash people can restore from, and say so, “Moved to Trash”.
- Draw the message while it is pointed at or focused, with any timer shown as paused.
Passes
- A strip at the top of the list that stays A pale blue strip above the inbox names the message that went, with Undo and a Close cross, #1f2933 on #eef4ff at 13.36:1 and Undo in #1a4fd0 at 6.19:1. It pushes the list down instead of floating over it, and stays until one is pressed or the next delete replaces it.
Rule of thumb: Show a message next to what it is about
- A light toast that times out into a Trash The toast says where the message went, “Moved to Trash”, and fades after four seconds, pausing while it is pointed at or has focus. The Trash link above the list, with its count, offers the same restore another way, so missing the toast costs a few steps, not the message.
Fails
Inbox
- Invoice for March
Message deleted.A pill with a countdown ring on UndoWCAG 2.2.1 The seconds count down in a ring on Undo, and the count stops while the toast is pointed at or has focus. That helps only people who reach it within four seconds: here it is one Tab away, but on a page it comes after the whole list, and a magnifier user has to find it first.
Verify the fix
4 checks, no mouse.
Test with: Screen reader, Keyboard, Zoom
Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the toast component or the delete flow changes.
How screen readers handle role="status"
Limits
This covers one kind of message, the confirmation of an action that can be undone. Errors, alerts that need an answer, and notifications from other people are topics of their own, and so is making sure the announcement is heard at all (see "Status messages that are shown but never announced"). Live regions and focus behave differently across screen readers and browsers. Test your real messages, at the pace your users work.
This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.
EaseWeb service
Fixed it? Keep it from coming back.
I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.