Skip to content

Commit

Permalink
Navigation: Fix ListView deprecation notice
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Jun 7, 2023
1 parent 80678f9 commit 524142e
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
);
Expand All @@ -116,13 +113,12 @@ const MainContent = ( {

return (
<div className="wp-block-navigation__menu-inspector-controls">
{ clientIdsTree.length === 0 && (
{ ! hasChildren && (
<p className="wp-block-navigation__menu-inspector-controls__empty-message">
{ __( 'This navigation menu is empty.' ) }
</p>
) }
<PrivateListView
blocks={ clientIdsTree }
rootClientId={ clientId }
isExpanded
description={ description }
Expand Down

0 comments on commit 524142e

Please sign in to comment.