diff --git a/packages/block-library/src/navigation/edit/menu-inspector-controls.js b/packages/block-library/src/navigation/edit/menu-inspector-controls.js index 9fd4bc3e33d41..4c450b1dda74c 100644 --- a/packages/block-library/src/navigation/edit/menu-inspector-controls.js +++ b/packages/block-library/src/navigation/edit/menu-inspector-controls.js @@ -103,7 +103,7 @@ const MainContent = ( { ? sprintf( /* translators: %s: The name of a menu. */ __( 'Structure for navigation menu: %s' ), - navigationMenu?.title?.rendered || __( 'Untitled menu' ) + navigationMenu?.title || __( 'Untitled menu' ) ) : __( 'You have not yet created any menus. Displaying a list of your Pages' 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 eebd3987b9b42..6de6927dea837 100644 --- a/packages/block-library/src/navigation/edit/navigation-menu-selector.js +++ b/packages/block-library/src/navigation/edit/navigation-menu-selector.js @@ -20,19 +20,19 @@ import useNavigationMenu from '../use-navigation-menu'; import useNavigationEntities from '../use-navigation-entities'; function buildMenuLabel( title, id, status ) { - if ( ! title?.rendered ) { + if ( ! title ) { /* translators: %s is the index of the menu in the list of menus. */ return sprintf( __( '(no title %s)' ), id ); } if ( status === 'publish' ) { - return decodeEntities( title?.rendered ); + return decodeEntities( title ); } return sprintf( // translators: %1s: title of the menu; %2s: status of the menu (draft, pending, etc.). __( '%1$s (%2$s)' ), - decodeEntities( title?.rendered ), + decodeEntities( title ), status ); } @@ -72,7 +72,11 @@ function NavigationMenuSelector( { const menuChoices = useMemo( () => { return ( navigationMenus?.map( ( { id, title, status }, index ) => { - const label = buildMenuLabel( title, index + 1, status ); + const label = buildMenuLabel( + title?.rendered, + index + 1, + status + ); return { value: id, diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js index c7dbf919324f6..07cddc81f85f0 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js @@ -135,8 +135,7 @@ function useDuplicateNavigationMenu() { useDispatch( noticesStore ); const handleDuplicate = async ( navigationMenu ) => { - const menuTitle = - navigationMenu?.title?.rendered || navigationMenu?.slug; + const menuTitle = navigationMenu?.title || navigationMenu?.slug; try { const savedRecord = await saveEntityRecord( diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js index 9d36e956cdca4..c6c91d443947f 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js @@ -25,19 +25,19 @@ import { unlock } from '../../lock-unlock'; // Copied from packages/block-library/src/navigation/edit/navigation-menu-selector.js. function buildMenuLabel( title, id, status ) { - if ( ! title?.rendered ) { + if ( ! title ) { /* translators: %s is the index of the menu in the list of menus. */ return sprintf( __( '(no title %s)' ), id ); } if ( status === 'publish' ) { - return decodeEntities( title?.rendered ); + return decodeEntities( title ); } return sprintf( // translators: %1s: title of the menu; %2s: status of the menu (draft, pending, etc.). __( '%1$s (%2$s)' ), - decodeEntities( title?.rendered ), + decodeEntities( title ), status ); } @@ -124,7 +124,7 @@ export default function SidebarNavigationScreenNavigationMenus() { withChevron icon={ navigation } > - { buildMenuLabel( title, index + 1, status ) } + { buildMenuLabel( title?.rendered, index + 1, status ) } ) ) } diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js index c5b9450ac7d8f..a124c4163fc54 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js @@ -23,7 +23,7 @@ export default function TemplatePartNavigationMenu( { id } ) { upperCase={ true } weight={ 500 } > - { title?.rendered || title || __( 'Navigation' ) } + { title || __( 'Navigation' ) }