mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
feat(toast-notification): clear timeout when destroyed
This commit is contained in:
parent
41c096bada
commit
7a612e60cf
1 changed files with 7 additions and 1 deletions
|
@ -21,14 +21,20 @@
|
|||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let timeoutId = undefined;
|
||||
let open = true;
|
||||
|
||||
onMount(() => {
|
||||
if (timeout) {
|
||||
window.setTimeout(() => {
|
||||
timeoutId = window.setTimeout(() => {
|
||||
open = false;
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.clearTimeout(timeoutId);
|
||||
timeoutId = undefined;
|
||||
};
|
||||
});
|
||||
|
||||
$: if (!open) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue