Skip to content

Commit 2866383

Browse files
authored
fix: cannot close notification manually (#11490)
1 parent 00ac7ed commit 2866383

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

web/app/components/base/toast/index.tsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,25 @@ Toast.notify = ({
123123
const holder = document.createElement('div')
124124
const root = createRoot(holder)
125125

126-
root.render(<Toast type={type} size={size} message={message} duration={duration} className={className} />)
126+
root.render(
127+
<ToastContext.Provider value={{
128+
notify: () => {},
129+
close: () => {
130+
if (holder) {
131+
root.unmount()
132+
holder.remove()
133+
}
134+
},
135+
}}>
136+
<Toast type={type} size={size} message={message} duration={duration} className={className} />
137+
</ToastContext.Provider>,
138+
)
127139
document.body.appendChild(holder)
128140
setTimeout(() => {
129-
if (holder)
141+
if (holder) {
142+
root.unmount()
130143
holder.remove()
144+
}
131145
}, duration || defaultDuring)
132146
}
133147
}

0 commit comments

Comments
 (0)