Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the navigation issue inside cover blocks #66093

Merged
6 changes: 5 additions & 1 deletion packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function useResponsiveMenu( navRef ) {
return;
}

const htmlElement = navRef.current.closest( 'html' );
const htmlElement = navRef.current.ownerDocument.documentElement;

// Add a `has-modal-open` class to the <html> when the responsive
// menu is open. This reproduces the same behavior of the frontend.
Expand All @@ -91,6 +91,10 @@ function useResponsiveMenu( navRef ) {
} else {
htmlElement.classList.remove( 'has-modal-open' );
}

return () => {
htmlElement.classList.remove( 'has-modal-open' );
renatho marked this conversation as resolved.
Show resolved Hide resolved
};
}, [ navRef, isResponsiveMenuOpen ] );

return [ isResponsiveMenuOpen, setResponsiveMenuVisibility ];
Expand Down
Loading