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 79ab409d62b60..cc8887a8785d9 100644 --- a/packages/block-library/src/navigation/edit/menu-inspector-controls.js +++ b/packages/block-library/src/navigation/edit/menu-inspector-controls.js @@ -32,6 +32,7 @@ const BLOCKS_WITH_LINK_UI_SUPPORT = [ 'core/navigation-link', 'core/navigation-submenu', ]; +const { PrivateListView } = unlock( blockEditorPrivateApis ); function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) { const { updateBlockAttributes } = useDispatch( blockEditorStore ); @@ -82,14 +83,9 @@ const MainContent = ( { isNavigationMenuMissing, onCreateNew, } ) => { - const { PrivateListView } = unlock( blockEditorPrivateApis ); - - // Provide a hierarchy of clientIds for the given Navigation block (clientId). - // This is required else the list view will display the entire block tree. - const clientIdsTree = useSelect( + const hasChildren = useSelect( ( select ) => { - const { __unstableGetClientIdsTree } = select( blockEditorStore ); - return __unstableGetClientIdsTree( clientId ); + return !! select( blockEditorStore ).getBlockCount( clientId ); }, [ clientId ] ); @@ -116,13 +112,12 @@ const MainContent = ( { return (
- { clientIdsTree.length === 0 && ( + { ! hasChildren && (

{ __( 'This navigation menu is empty.' ) }

) }