diff --git a/app/components/ui-lib.tsx b/app/components/ui-lib.tsx index 4af37dbba..5d52bef59 100644 --- a/app/components/ui-lib.tsx +++ b/app/components/ui-lib.tsx @@ -229,13 +229,19 @@ export function showToast( content: string, action?: ToastProps["action"], delay = 3000, -) { +): () => void { const div = document.createElement("div"); div.className = styles.show; document.body.appendChild(div); const root = createRoot(div); + let closeCalled = false; const close = () => { + if (closeCalled) { + return; + } else { + closeCalled = true; + } div.classList.add(styles.hide); setTimeout(() => { @@ -249,6 +255,8 @@ export function showToast( }, delay); root.render(); + + return close; } export type InputProps = React.HTMLProps & {