From 8b5f01b0a34eb402f5e3883df80a3716b0a7f1ee Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 8 Jun 2023 08:19:36 +0300 Subject: [PATCH] Navigation: Fix ListView deprecation notice (#51094) * Navigation: Fix ListView deprecation notice * Unlock component at the file level --- .../src/navigation/edit/menu-inspector-controls.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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 79ab409d62b602..cc8887a8785d96 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.' ) }

) }