diff --git a/packages/block-library/src/navigation/view.js b/packages/block-library/src/navigation/view.js index 8fcc5527c6042c..c9e0a78d6a2a3e 100644 --- a/packages/block-library/src/navigation/view.js +++ b/packages/block-library/src/navigation/view.js @@ -31,7 +31,7 @@ const closeMenu = ( { context, selectors }, menuClosedOn ) => { // Check if the menu is still open or not. if ( ! selectors.core.navigation.isMenuOpen( { context } ) ) { if ( - context.core.navigation.modal.contains( + context.core.navigation.modal?.contains( window.document.activeElement ) ) { @@ -155,7 +155,7 @@ store( { // `window.document.activeElement` doesn't change if ( context.core.navigation.isMenuOpen.click && - ! context.core.navigation.modal.contains( + ! context.core.navigation.modal?.contains( event.relatedTarget ) && event.target !== window.document.activeElement