mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
Merge pull request #207 from IBM/fix-modal-ssr
fix(modal): replace onDestroy with onMount for SSR support
This commit is contained in:
commit
cd340d1fc2
1 changed files with 7 additions and 5 deletions
|
@ -17,7 +17,7 @@
|
|||
export let id = "ccs-" + Math.random().toString(36);
|
||||
export let ref = null;
|
||||
|
||||
import { createEventDispatcher, afterUpdate, onDestroy } from "svelte";
|
||||
import { createEventDispatcher, onMount, afterUpdate } from "svelte";
|
||||
import Close20 from "carbon-icons-svelte/lib/Close20";
|
||||
import { Button } from "../Button";
|
||||
|
||||
|
@ -33,6 +33,12 @@
|
|||
node.focus();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
return () => {
|
||||
document.body.classList.remove("bx--body--with-modal-open");
|
||||
};
|
||||
});
|
||||
|
||||
afterUpdate(() => {
|
||||
if (opened) {
|
||||
if (!open) {
|
||||
|
@ -48,10 +54,6 @@
|
|||
}
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
document.body.classList.remove("bx--body--with-modal-open");
|
||||
});
|
||||
|
||||
$: modalLabelId = `bx--modal-header__label--modal-${id}`;
|
||||
$: modalHeadingId = `bx--modal-header__heading--modal-${id}`;
|
||||
$: ariaLabel =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue