From cd2193f50c035dc6d3ea136fd7fd919c01a4b4ac Mon Sep 17 00:00:00 2001 From: Adam Antal Date: Fri, 17 Nov 2023 11:35:12 +0100 Subject: [PATCH] Only enable body scrolling after closing the last modal, not after every --- src/core/modal.slice.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/modal.slice.ts b/src/core/modal.slice.ts index d1645c3371..cc25522f4a 100644 --- a/src/core/modal.slice.ts +++ b/src/core/modal.slice.ts @@ -70,8 +70,6 @@ const modalSlice = createSlice({ } }, closeModal(state: StateProps, action: PayloadProps) { - // Enables background scrolling to use when Modal is closed - document.body.style.overflow = ""; const modalId = state.modalIds.pop(); if (state.modalIds.indexOf(action.payload.modalId) > -1) { state.modalIds.splice( @@ -83,6 +81,12 @@ const modalSlice = createSlice({ removeModalIdFromUrl(state); returnFocusElement(); } + // Enables background scrolling to use when last modal is closed + // console.log(getConf("modalIds", configuration)); + // console.log(state.modalIds.length); + if (state.modalIds.length === 0) { + document.body.style.overflow = ""; + } }, closeLastModal(state: StateProps) { // Enables background scrolling to use when Modal is closed