From 912dfe01d9745d92018b9a08f52c1551b07df1e3 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 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.' ) }

) }