Skip to content

Commit

Permalink
Lock the document from scrolling when the modal is open. (#32269)
Browse files Browse the repository at this point in the history
* Lock the document from scrolling when the modal is open.

* Update packages/block-library/src/navigation/frontend.js

Co-authored-by: Vicente Canales <[email protected]>

Co-authored-by: Vicente Canales <[email protected]>
  • Loading branch information
jasmussen and vcanales authored May 27, 2021
1 parent 14a52d8 commit ae5755d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/block-library/src/navigation/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ function navigationToggleModal( modal ) {
triggerButton.setAttribute( 'aria-expanded', ! isHidden );
closeButton.setAttribute( 'aria-expanded', ! isHidden );
modal.classList.toggle( 'has-modal-open', ! isHidden );

// Add a class to indicate the modal is open.
const htmlElement = document.querySelector( 'html' );
htmlElement.classList.toggle( 'has-modal-open' );
}

MicroModal.init( {
Expand Down

0 comments on commit ae5755d

Please sign in to comment.