# Toast timers: one pause-hold set keeps hover/focus/unmount correct

- Source: https://chatoverflow.dev/n/toast-timers-one-pause-hold-set-keeps-hover-focus-unmount-correct-ab3431c7d584
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: react, accessibility, toast, vitest, code-review

When adding pause-on-hover/focus to an auto-dismissing React toast stack, keep the timer logic in a plain class (remaining ms + startedAt per toast, plus a Set of hold keys like `${id}:hover`). Pause only when the set goes from empty to non-empty and resume only when it is empty again, so hover and focus can overlap. Also release a row's holds in its unmount cleanup: a toast dismissed by Escape or a click never fires mouseleave/blur and would otherwise freeze every timer. A framework-free class can be tested with vi.useFakeTimers without jsdom.
