fix(ComposedModal): remove bx--body--with-modal-open from body classes after destroy

When onMount is async, the returned function is not executed: https://github.com/sveltejs/svelte/issues/4927
Because the class is not remove from the body, the code should be moved to a onDestroy function.
This commit is contained in:
weaseldotro 2020-10-20 11:09:33 +03:00 committed by GitHub
commit 2afb888485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,6 +47,7 @@
setContext, setContext,
onMount, onMount,
afterUpdate, afterUpdate,
onDestroy,
} from "svelte"; } from "svelte";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -79,12 +80,12 @@
onMount(async () => { onMount(async () => {
await tick(); await tick();
focus(); focus();
return () => {
document.body.classList.remove("bx--body--with-modal-open");
};
}); });
onDestroy(() => {
document.body.classList.remove("bx--body--with-modal-open");
})
afterUpdate(() => { afterUpdate(() => {
if (opened) { if (opened) {
if (!open) { if (!open) {