From 2866383228cc490042126863cb104c70ec3410db Mon Sep 17 00:00:00 2001 From: Hash Brown Date: Mon, 9 Dec 2024 17:55:06 +0800 Subject: [PATCH] fix: cannot close notification manually (#11490) --- web/app/components/base/toast/index.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/web/app/components/base/toast/index.tsx b/web/app/components/base/toast/index.tsx index b1b9ffe8c4e9d8..b9a6de9fe5ac00 100644 --- a/web/app/components/base/toast/index.tsx +++ b/web/app/components/base/toast/index.tsx @@ -123,11 +123,25 @@ Toast.notify = ({ const holder = document.createElement('div') const root = createRoot(holder) - root.render() + root.render( + {}, + close: () => { + if (holder) { + root.unmount() + holder.remove() + } + }, + }}> + + , + ) document.body.appendChild(holder) setTimeout(() => { - if (holder) + if (holder) { + root.unmount() holder.remove() + } }, duration || defaultDuring) } }