mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-13 18:19:00 +08:00
fix: cannot close notification manually (#11490)
This commit is contained in:
parent
00ac7edeb3
commit
2866383228
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user