Skip to content

Commit

Permalink
fix: cannot close notification manually (#11490)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzuodong authored Dec 9, 2024
1 parent 00ac7ed commit 2866383
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions web/app/components/base/toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,25 @@ Toast.notify = ({
const holder = document.createElement('div')
const root = createRoot(holder)

root.render(<Toast type={type} size={size} message={message} duration={duration} className={className} />)
root.render(
<ToastContext.Provider value={{
notify: () => {},
close: () => {
if (holder) {
root.unmount()
holder.remove()
}
},
}}>
<Toast type={type} size={size} message={message} duration={duration} className={className} />
</ToastContext.Provider>,
)
document.body.appendChild(holder)
setTimeout(() => {
if (holder)
if (holder) {
root.unmount()
holder.remove()
}
}, duration || defaultDuring)
}
}
Expand Down

0 comments on commit 2866383

Please sign in to comment.