Skip to content

Commit

Permalink
Fix Choose menu label when a menu has been deleted. (WordPress#67009)
Browse files Browse the repository at this point in the history
* Fix Choose menu label when a menu has been deleted.

* Pass menu ID to useNavigationMenu.

Co-authored-by: afercia <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: draganescu <[email protected]>
  • Loading branch information
4 people authored Dec 17, 2024
1 parent 7dd3127 commit 6e274de
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ function NavigationMenuSelector( {
hasResolvedNavigationMenus,
canUserCreateNavigationMenus,
canSwitchNavigationMenu,
} = useNavigationMenu();
isNavigationMenuMissing,
} = useNavigationMenu( currentMenuId );

const [ currentTitle ] = useEntityProp(
'postType',
Expand Down Expand Up @@ -106,12 +107,18 @@ function NavigationMenuSelector( {
const noBlockMenus = ! hasNavigationMenus && hasResolvedNavigationMenus;
const menuUnavailable =
hasResolvedNavigationMenus && currentMenuId === null;
const navMenuHasBeenDeleted = currentMenuId && isNavigationMenuMissing;

let selectorLabel = '';

if ( isResolvingNavigationMenus ) {
selectorLabel = __( 'Loading…' );
} else if ( noMenuSelected || noBlockMenus || menuUnavailable ) {
} else if (
noMenuSelected ||
noBlockMenus ||
menuUnavailable ||
navMenuHasBeenDeleted
) {
// Note: classic Menus may be available.
selectorLabel = __( 'Choose or create a Navigation Menu' );
} else {
Expand Down

0 comments on commit 6e274de

Please sign in to comment.