Skip to content
easeweb
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.

WCAG 2.2
SC 2.2.1A
Required by
Section 508 · EN 301 549 (EU)
Broken setTimeout(…, 4000)
The accessibility problem illustrated: No vision:It vanished before I could undo.
01

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

02

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?

BrokenAn Undo toast that closes after four seconds
  • Lunch on Friday
  • Invoice for March
  • Team photos
  • Weekly report

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Don't let a timer take away an action people need

Before
BrokenAn Undo toast that closes after four seconds
<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.
After

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
  1. Drop the setTimeout. The toast keeps its look and its announcement, but no timer removes it.
  2. Add a Close button beside Undo, so it goes when the person presses Undo or Close.
  3. Show it with replaceChildren(), so the next toast replaces it.
  4. 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.

04

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

  • Inbox

    Deleted “Lunch on Friday”.
    • Invoice for March
    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.
  • 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.
05

Verify the fix

4 checks, no mouse.

Test with: Screen reader, Keyboard, Zoom

0 of 4 checked

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.

See the service