Disable page scroll when Mini Cart is open (https://github.com/woocommerce/woocommerce-blocks/pull/6532)
This commit is contained in:
parent
d994f06803
commit
b5252dbd8f
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue