Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Disable page scroll when Mini Cart is open (#6532)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu authored Jun 9, 2022
1 parent 0f6cda9 commit b7fab6d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions assets/js/blocks/mini-cart/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ const MiniCartBlock = ( {
setContentsNode( node );
}, [] );

useEffect( () => {
const body = document.querySelector( 'body' );
if ( body ) {
if ( isOpen ) {
Object.assign( body.style, { overflow: 'hidden' } );
} else {
Object.assign( body.style, { overflow: '' } );
}
}
}, [ isOpen ] );

useEffect( () => {
if ( contentsNode instanceof Element ) {
const container = contentsNode.querySelector(
Expand Down

0 comments on commit b7fab6d

Please sign in to comment.