From 497d5dc877dd845174e90981a4d127e5aa84f699 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Wed, 14 Dec 2022 13:48:48 +0000 Subject: [PATCH 1/3] Navigation: Pass a tree of client ids instead of an array of blocks. Co-authored-by: Daniel Richards <677833+talldan@users.noreply.github.com> --- .../src/components/off-canvas-editor/block.js | 2 +- .../block-library/src/navigation/edit/index.js | 6 +++--- .../src/navigation/edit/menu-inspector-controls.js | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/off-canvas-editor/block.js b/packages/block-editor/src/components/off-canvas-editor/block.js index af74873e1b41a..49ce5788dfafe 100644 --- a/packages/block-editor/src/components/off-canvas-editor/block.js +++ b/packages/block-editor/src/components/off-canvas-editor/block.js @@ -145,7 +145,7 @@ function ListViewBlock( { const { isTreeGridMounted, expand, collapse } = useListViewContext(); - const isEditable = block.name !== 'core/page-list-item'; + const isEditable = blockName !== 'core/page-list-item'; const hasSiblings = siblingBlockCount > 0; const hasRenderedMovers = showBlockMovers && hasSiblings; const moverCellClassName = classnames( diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index b414409791cbf..d94e0022d15ea 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -717,13 +717,13 @@ function Navigation( { return ( { + const { __unstableGetClientIdsTree } = select( blockEditorStore ); + return __unstableGetClientIdsTree( clientId ); + }, + [ clientId ] + ); + return ( { isOffCanvasNavigationEditorEnabled ? ( From 772aad9c4baad2f8fae29039bcbf7bdaceecbb42 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Wed, 14 Dec 2022 15:53:41 +0000 Subject: [PATCH 2/3] Explain passing custom clientIDs --- .../src/navigation/edit/menu-inspector-controls.js | 2 ++ 1 file changed, 2 insertions(+) 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 28af66077b0c1..98d49f0c81feb 100644 --- a/packages/block-library/src/navigation/edit/menu-inspector-controls.js +++ b/packages/block-library/src/navigation/edit/menu-inspector-controls.js @@ -34,6 +34,8 @@ const MenuInspectorControls = ( { /* translators: %s: The name of a menu. */ const actionLabel = __( "Switch to '%s'" ); + // 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( ( select ) => { const { __unstableGetClientIdsTree } = select( blockEditorStore ); From e434905f13b43e5f2f45938da37f957990d0f46a Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Wed, 14 Dec 2022 16:11:19 +0000 Subject: [PATCH 3/3] remove whitespace for linter? --- .../src/navigation/edit/menu-inspector-controls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 98d49f0c81feb..5d70d1b165431 100644 --- a/packages/block-library/src/navigation/edit/menu-inspector-controls.js +++ b/packages/block-library/src/navigation/edit/menu-inspector-controls.js @@ -35,7 +35,7 @@ const MenuInspectorControls = ( { const actionLabel = __( "Switch to '%s'" ); // Provide a hierarchy of clientIds for the given Navigation block (clientId). - // This is required else the list view will display the entire block tree. + // This is required else the list view will display the entire block tree. const clientIdsTree = useSelect( ( select ) => { const { __unstableGetClientIdsTree } = select( blockEditorStore );