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:
weaseldotro 2020-11-07 21:09:05 +02:00 committed by GitHub
commit cf5998e313
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -132,7 +132,9 @@
onMount(() => { onMount(() => {
return () => { return () => {
document.body.classList.remove("bx--body--with-modal-open"); if(document.querySelectorAll('.bx--modal.is-visible').length === 0) {
document.body.classList.remove("bx--body--with-modal-open");
}
}; };
}); });
@ -141,7 +143,9 @@
if (!open) { if (!open) {
opened = false; opened = false;
dispatch("close"); dispatch("close");
document.body.classList.remove("bx--body--with-modal-open"); if(document.querySelectorAll('.bx--modal.is-visible').length === 0) {
document.body.classList.remove("bx--body--with-modal-open");
}
} }
} else if (open) { } else if (open) {
opened = true; opened = true;