mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
fix(Modal): remove bx--body--with-modal-open from body only when there are no visible modals
If multiple modals are used, this correctly handles the cleanup after the modals close.
This commit is contained in:
parent
4d17329c3a
commit
cf5998e313
1 changed files with 6 additions and 2 deletions
|
@ -132,7 +132,9 @@
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
return () => {
|
return () => {
|
||||||
|
if(document.querySelectorAll('.bx--modal.is-visible').length === 0) {
|
||||||
document.body.classList.remove("bx--body--with-modal-open");
|
document.body.classList.remove("bx--body--with-modal-open");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -141,8 +143,10 @@
|
||||||
if (!open) {
|
if (!open) {
|
||||||
opened = false;
|
opened = false;
|
||||||
dispatch("close");
|
dispatch("close");
|
||||||
|
if(document.querySelectorAll('.bx--modal.is-visible').length === 0) {
|
||||||
document.body.classList.remove("bx--body--with-modal-open");
|
document.body.classList.remove("bx--body--with-modal-open");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (open) {
|
} else if (open) {
|
||||||
opened = true;
|
opened = true;
|
||||||
focus();
|
focus();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue