From be02746c89af24ea2ee490c9b49a77aecccbd15f Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 16 Nov 2021 16:28:02 +0800 Subject: [PATCH 1/2] Fix missing menu detection --- .../block-library/src/navigation/use-navigation-menu.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/use-navigation-menu.js b/packages/block-library/src/navigation/use-navigation-menu.js index cd58adf0684fa..90e32c88ffb83 100644 --- a/packages/block-library/src/navigation/use-navigation-menu.js +++ b/packages/block-library/src/navigation/use-navigation-menu.js @@ -8,6 +8,7 @@ export default function useNavigationMenu( navigationMenuId ) { return useSelect( ( select ) => { const { + getEntityRecord, getEditedEntityRecord, getEntityRecords, hasFinishedResolution, @@ -18,6 +19,9 @@ export default function useNavigationMenu( navigationMenuId ) { 'wp_navigation', navigationMenuId, ]; + const rawNavigationMenu = navigationMenuId + ? getEntityRecord( ...navigationMenuSingleArgs ) + : null; const navigationMenu = navigationMenuId ? getEditedEntityRecord( ...navigationMenuSingleArgs ) : null; @@ -45,7 +49,7 @@ export default function useNavigationMenu( navigationMenuId ) { isNavigationMenuResolved: hasResolvedNavigationMenu, isNavigationMenuMissing: ! navigationMenuId || - ( hasResolvedNavigationMenu && ! navigationMenu ), + ( hasResolvedNavigationMenu && ! rawNavigationMenu ), canSwitchNavigationMenu, hasResolvedNavigationMenus: hasFinishedResolution( 'getEntityRecords', From 2e6238080fad777e9b817be8a57f33b82c7eaeb6 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Tue, 16 Nov 2021 16:29:44 +0800 Subject: [PATCH 2/2] Remove warning state, just fall back to placeholder --- .../block-library/src/navigation/edit/index.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index e51aa40a9677e..ae6b498143d1e 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -283,20 +283,6 @@ function Navigation( { ); } - // Show a warning if the selected menu is no longer available. - // TODO - the user should be able to select a new one? - if ( navigationMenuId && isNavigationMenuMissing ) { - return ( -
- - { __( - 'Navigation menu has been deleted or is unavailable' - ) } - -
- ); - } - if ( isEntityAvailable && hasAlreadyRendered ) { return (