Skip to content

Commit

Permalink
Only enable body scrolling after closing the last modal, not after every
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamik10 committed Nov 17, 2023
1 parent 0d8c510 commit cd2193f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/modal.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit cd2193f

Please sign in to comment.