From 7e52fbb7a7e6d4329c4cc0c2667e3af5e8c67a34 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Thu, 12 Jan 2023 17:27:42 +0000 Subject: [PATCH] Ensure appropriate fallback menu title in Nav block menu selector (#47073) * Ensure appropriate fallback * Change the untitled name Co-authored-by: Ben Dwyer --- .../src/navigation/edit/navigation-menu-selector.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/navigation/edit/navigation-menu-selector.js b/packages/block-library/src/navigation/edit/navigation-menu-selector.js index a9f3abceaaa375..0b2c454fc41032 100644 --- a/packages/block-library/src/navigation/edit/navigation-menu-selector.js +++ b/packages/block-library/src/navigation/edit/navigation-menu-selector.js @@ -68,8 +68,12 @@ function NavigationMenuSelector( { const menuChoices = useMemo( () => { return ( - navigationMenus?.map( ( { id, title } ) => { - const label = decodeEntities( title.rendered ); + navigationMenus?.map( ( { id, title }, index ) => { + const label = + decodeEntities( title.rendered ) || + /* translators: %s is the index of the menu in the list of menus. */ + sprintf( __( '(no title %s)' ), index + 1 ); + if ( id === currentMenuId && ! isCreatingMenu ) { setSelectorLabel( /* translators: %s is the name of a navigation menu. */