mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
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:
parent
11f3b9ec06
commit
2afb888485
1 changed files with 5 additions and 4 deletions
|
@ -47,6 +47,7 @@
|
|||
setContext,
|
||||
onMount,
|
||||
afterUpdate,
|
||||
onDestroy,
|
||||
} from "svelte";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
@ -79,12 +80,12 @@
|
|||
onMount(async () => {
|
||||
await tick();
|
||||
focus();
|
||||
|
||||
return () => {
|
||||
document.body.classList.remove("bx--body--with-modal-open");
|
||||
};
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
document.body.classList.remove("bx--body--with-modal-open");
|
||||
})
|
||||
|
||||
afterUpdate(() => {
|
||||
if (opened) {
|
||||
if (!open) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue