mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +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 id = "ccs-" + Math.random().toString(36);
|
||||||
export let ref = null;
|
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 Close20 from "carbon-icons-svelte/lib/Close20";
|
||||||
import { Button } from "../Button";
|
import { Button } from "../Button";
|
||||||
|
|
||||||
|
@ -33,6 +33,12 @@
|
||||||
node.focus();
|
node.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
return () => {
|
||||||
|
document.body.classList.remove("bx--body--with-modal-open");
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
afterUpdate(() => {
|
afterUpdate(() => {
|
||||||
if (opened) {
|
if (opened) {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
|
@ -48,10 +54,6 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(() => {
|
|
||||||
document.body.classList.remove("bx--body--with-modal-open");
|
|
||||||
});
|
|
||||||
|
|
||||||
$: modalLabelId = `bx--modal-header__label--modal-${id}`;
|
$: modalLabelId = `bx--modal-header__label--modal-${id}`;
|
||||||
$: modalHeadingId = `bx--modal-header__heading--modal-${id}`;
|
$: modalHeadingId = `bx--modal-header__heading--modal-${id}`;
|
||||||
$: ariaLabel =
|
$: ariaLabel =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue