fix(ComposedModal): 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:
weaseldotro 2020-11-07 21:07:14 +02:00 committed by GitHub
commit 4d17329c3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -83,7 +83,9 @@
});
onDestroy(() => {
if(document.querySelectorAll('.bx--modal.is-visible').length === 0) {
document.body.classList.remove("bx--body--with-modal-open");
}
});
afterUpdate(() => {
@ -91,8 +93,10 @@
if (!open) {
opened = false;
dispatch("close");
if(document.querySelectorAll('.bx--modal.is-visible').length === 0) {
document.body.classList.remove("bx--body--with-modal-open");
}
}
} else if (open) {
opened = true;
dispatch("open");