fix(dropdown): fix ssr issue (#1639)

The `onDestroy` hook is also run during SSR, so returning destruction function from `onMount` should do the trick. For #1638
This commit is contained in:
ptrxyz 2023-01-25 04:28:36 +01:00 committed by GitHub
commit 8cb5d538f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -98,7 +98,7 @@
/** Obtain a reference to the button HTML element */
export let ref = null;
import { createEventDispatcher, onDestroy, onMount } from "svelte";
import { createEventDispatcher, onMount } from "svelte";
import WarningFilled from "../icons/WarningFilled.svelte";
import WarningAltFilled from "../icons/WarningAltFilled.svelte";
import {
@ -159,11 +159,11 @@
if (parent) {
parent.addEventListener("click", pageClickHandler);
}
});
onDestroy(() => {
if (parent) {
parent.removeEventListener("click", pageClickHandler);
return () => {
if (parent) {
parent.removeEventListener("click", pageClickHandler);
}
}
});
</script>