Skip to content

Commit

Permalink
fix(MWPW-136057):background scrolls when modal is open fixed (#1234)
Browse files Browse the repository at this point in the history
background scrolls when modal is open fixed
  • Loading branch information
sharath-kannan authored Sep 11, 2023
1 parent 4d31417 commit 4ca99ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libs/blocks/modal/modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@
column-count: 1;
}

.modal-open {
overflow: hidden;
}

@media (min-width: 600px) {
.dialog-modal {
max-width: 80vw;
Expand Down
3 changes: 2 additions & 1 deletion libs/blocks/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function sendAnalytics(event) {
function closeModal(modal) {
const { id } = modal;
const closeEvent = new Event('milo:modal:closed');
document.body.classList.remove('modal-open');
window.dispatchEvent(closeEvent);
const localeModal = id?.includes('locale-modal') ? 'localeModal' : 'milo';
const analyticsEventName = window.location.hash ? window.location.hash.replace('#', '') : localeModal;
Expand Down Expand Up @@ -107,7 +108,7 @@ export async function sendViewportDimensionsOnRequest(messageInfo) {

export async function getModal(details, custom) {
if (!(details?.path || custom)) return null;

document.body.classList.add('modal-open');
const { id } = details || custom;

const dialog = createTag('div', { class: 'dialog-modal', id });
Expand Down

0 comments on commit 4ca99ec

Please sign in to comment.