From cf5998e313e6226454fbc44565d463c8d7339c01 Mon Sep 17 00:00:00 2001 From: weaseldotro <1822852+weaseldotro@users.noreply.github.com> Date: Sat, 7 Nov 2020 21:09:05 +0200 Subject: [PATCH] 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. --- src/Modal/Modal.svelte | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Modal/Modal.svelte b/src/Modal/Modal.svelte index 3f12276f..4f123138 100644 --- a/src/Modal/Modal.svelte +++ b/src/Modal/Modal.svelte @@ -132,7 +132,9 @@ onMount(() => { 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) { 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;