Skip to content

Commit

Permalink
Navigation: Fix ListView deprecation notice (#51094)
Browse files Browse the repository at this point in the history
* Navigation: Fix ListView deprecation notice

* Unlock component at the file level
  • Loading branch information
Mamaduka authored Jun 8, 2023
1 parent 34af582 commit 912dfe0
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ]
);
Expand All @@ -116,13 +112,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

1 comment on commit 912dfe0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 912dfe0.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5207680593
📝 Reported issues:

Please sign in to comment.