From 4d17329c3abc8aee3077e4fb073a83b03bf4a0e6 Mon Sep 17 00:00:00 2001 From: weaseldotro <1822852+weaseldotro@users.noreply.github.com> Date: Sat, 7 Nov 2020 21:07:14 +0200 Subject: [PATCH] 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. --- src/ComposedModal/ComposedModal.svelte | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ComposedModal/ComposedModal.svelte b/src/ComposedModal/ComposedModal.svelte index f0ea91a2..44c62f9d 100644 --- a/src/ComposedModal/ComposedModal.svelte +++ b/src/ComposedModal/ComposedModal.svelte @@ -83,7 +83,9 @@ }); onDestroy(() => { - 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"); + } }); afterUpdate(() => { @@ -91,7 +93,9 @@ if (!open) { opened = false; 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) { opened = true;