mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
fix: clear timeout in onMount return function
This commit is contained in:
parent
bd6bd15c79
commit
fff54a19eb
3 changed files with 23 additions and 21 deletions
|
@ -17,19 +17,18 @@
|
|||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
$: open = true;
|
||||
$: timeoutId = undefined;
|
||||
let open = true;
|
||||
let timeoutId = undefined;
|
||||
|
||||
onMount(() => {
|
||||
if (timeout) {
|
||||
timeoutId = window.setTimeout(() => {
|
||||
timeoutId = setTimeout(() => {
|
||||
open = false;
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.clearTimeout(timeoutId);
|
||||
timeoutId = undefined;
|
||||
clearTimeout(timeoutId);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue