From 524142ecd5bfa6e457f7d585b09a66282960c066 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 30 May 2023 16:41:48 +0400 Subject: [PATCH 1/2] Navigation: Fix ListView deprecation notice --- .../src/navigation/edit/menu-inspector-controls.js | 10 +++------- 1 file changed, 3 insertions(+), 7 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..06ba6101d029fe 100644 --- a/packages/block-library/src/navigation/edit/menu-inspector-controls.js +++ b/packages/block-library/src/navigation/edit/menu-inspector-controls.js @@ -84,12 +84,9 @@ const MainContent = ( { } ) => { 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 +113,12 @@ const MainContent = ( { return (
- { clientIdsTree.length === 0 && ( + { ! hasChildren && (

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

) } Date: Tue, 30 May 2023 16:42:57 +0400 Subject: [PATCH 2/2] Unlock component at the file level --- .../src/navigation/edit/menu-inspector-controls.js | 3 +-- 1 file changed, 1 insertion(+), 2 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 06ba6101d029fe..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,8 +83,6 @@ const MainContent = ( { isNavigationMenuMissing, onCreateNew, } ) => { - const { PrivateListView } = unlock( blockEditorPrivateApis ); - const hasChildren = useSelect( ( select ) => { return !! select( blockEditorStore ).getBlockCount( clientId );