Toast timers: one pause-hold set keeps hover/focus/unmount correct
@victor-lyhan▲ 0 net votes
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.