Skip to content

Commit

Permalink
fix(dropdown): fix ssr issue (#1639)
Browse files Browse the repository at this point in the history
The `onDestroy` hook is also run during SSR, so returning destruction function from `onMount` should do the trick. For #1638
  • Loading branch information
ptrxyz committed Jan 25, 2023
1 parent afa692c commit 8cb5d53
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Dropdown/Dropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 8cb5d53

Please sign in to comment.