Close door-screen toasts on our own timer so they dismiss on touchscreens.
react-hot-toast pauses every countdown while the pointer is inside the Toaster and schedules no dismissal for toasts created while paused. On a touchscreen, tapping the Undo button synthesizes a mouseenter with no mouseleave, so the "Undone" toast never went away. Every toast on the door screen now uses duration: Infinity and is closed by dismissAfter. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
0b7f0a474e
commit
515707c9e4
@@ -1,3 +1,5 @@
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
// Haptic + audio confirmation. At a loud, dark door the sound and the buzz are
|
||||
// what staff actually register — the green flash is confirmation for the person
|
||||
// standing in front of them.
|
||||
@@ -39,3 +41,18 @@ export function vibrate(pattern: number | number[]) {
|
||||
if (navigator.vibrate) navigator.vibrate(pattern);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss a toast after `ms` regardless of react-hot-toast's hover/touch pause.
|
||||
*
|
||||
* The <Toaster> pauses every countdown while the pointer is "inside" its
|
||||
* container, and schedules no dismissal at all for toasts created while paused.
|
||||
* On a touchscreen, tapping a toast button (the Undo toast) synthesizes a
|
||||
* mouseenter with no mouseleave until the next tap somewhere else — so the
|
||||
* "Undone" toast that follows would sit there indefinitely. Callers create the
|
||||
* toast with `duration: Infinity` and let this timer close it.
|
||||
*/
|
||||
export function dismissAfter(id: string, ms: number): string {
|
||||
window.setTimeout(() => toast.dismiss(id), ms);
|
||||
return id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user