diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index b44a5ef142777..48d1bd708b67b 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -319,6 +319,15 @@ function Navigation( { setNavigationMenuId( id ); onClose(); } } + onCreateNew={ () => { + if ( navigationArea ) { + setAreaMenu( 0 ); + } + setAttributes( { + navigationMenuId: undefined, + } ); + setIsPlaceholderShown( true ); + } } /> ) } 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 c696019cd2b7e..f915fb268e3fe 100644 --- a/packages/block-library/src/navigation/edit/navigation-menu-selector.js +++ b/packages/block-library/src/navigation/edit/navigation-menu-selector.js @@ -1,34 +1,42 @@ /** * WordPress dependencies */ -import { MenuGroup, MenuItemsChoice } from '@wordpress/components'; +import { MenuGroup, MenuItem, MenuItemsChoice } from '@wordpress/components'; import { useEntityId } from '@wordpress/core-data'; +import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import useNavigationMenu from '../use-navigation-menu'; -export default function NavigationMenuSelector( { onSelect } ) { +export default function NavigationMenuSelector( { onSelect, onCreateNew } ) { const { navigationMenus } = useNavigationMenu(); const navigationMenuId = useEntityId( 'postType', 'wp_navigation' ); return ( - - - onSelect( - navigationMenus.find( - ( post ) => post.id === selectedId + <> + + + onSelect( + navigationMenus.find( + ( post ) => post.id === selectedId + ) ) - ) - } - choices={ navigationMenus.map( ( { id, title } ) => ( { - value: id, - label: title.rendered, - } ) ) } - /> - + } + choices={ navigationMenus.map( ( { id, title } ) => ( { + value: id, + label: title.rendered, + } ) ) } + /> + + + + { __( 'Create new menu' ) } + + + ); }