From b9e59f384d6d47519f220d2849f466613910b0fb Mon Sep 17 00:00:00 2001 From: Copons Date: Wed, 28 Apr 2021 16:16:30 +0100 Subject: [PATCH 1/7] Simplify the BlockNavigation component --- .../src/components/block-navigation/index.js | 60 +------------- .../src/components/block-navigation/tree.js | 38 ++++++++- .../use-block-navigation-client-ids.js | 78 +++++++++++++++++++ .../src/navigation/block-navigation-list.js | 25 ++---- .../secondary-sidebar/list-view-sidebar.js | 16 +--- 5 files changed, 124 insertions(+), 93 deletions(-) create mode 100644 packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js diff --git a/packages/block-editor/src/components/block-navigation/index.js b/packages/block-editor/src/components/block-navigation/index.js index 48c20ae9ae144..ddee5b315f73d 100644 --- a/packages/block-editor/src/components/block-navigation/index.js +++ b/packages/block-editor/src/components/block-navigation/index.js @@ -1,68 +1,17 @@ -/** - * External dependencies - */ -import { isArray, noop } from 'lodash'; - /** * WordPress dependencies */ -import { useDispatch, useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import BlockNavigationTree from './tree'; -import { isClientIdSelected } from './utils'; -import { store as blockEditorStore } from '../../store'; export default function BlockNavigation( { - onSelect = noop, + onSelect = () => {}, __experimentalFeatures, } ) { - const { rootBlock, rootBlocks, selectedBlockClientId } = useSelect( - ( select ) => { - const { - getBlockHierarchyRootClientId, - getSelectedBlockClientId, - __unstableGetClientIdsTree, - __unstableGetClientIdWithClientIdsTree, - } = select( blockEditorStore ); - - const _selectedBlockClientId = getSelectedBlockClientId(); - const _rootBlocks = __unstableGetClientIdsTree(); - const _rootBlock = - _selectedBlockClientId && ! isArray( _selectedBlockClientId ) - ? __unstableGetClientIdWithClientIdsTree( - getBlockHierarchyRootClientId( - _selectedBlockClientId - ) - ) - : null; - - return { - rootBlock: _rootBlock, - rootBlocks: _rootBlocks, - selectedBlockClientId: _selectedBlockClientId, - }; - } - ); - const { selectBlock } = useDispatch( blockEditorStore ); - - function selectEditorBlock( clientId ) { - selectBlock( clientId ); - onSelect( clientId ); - } - - if ( ! rootBlocks || rootBlocks.length === 0 ) { - return null; - } - - const hasHierarchy = - rootBlock && - ( ! isClientIdSelected( rootBlock.clientId, selectedBlockClientId ) || - ( rootBlock.innerBlocks && rootBlock.innerBlocks.length !== 0 ) ); - return (

@@ -70,11 +19,10 @@ export default function BlockNavigation( {

); diff --git a/packages/block-editor/src/components/block-navigation/tree.js b/packages/block-editor/src/components/block-navigation/tree.js index e1a9b4a8302b7..ccb23a6dd0d76 100644 --- a/packages/block-editor/src/components/block-navigation/tree.js +++ b/packages/block-editor/src/components/block-navigation/tree.js @@ -3,29 +3,54 @@ */ import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components'; +import { useDispatch } from '@wordpress/data'; import { useEffect, useMemo, useRef } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; + /** * Internal dependencies */ import BlockNavigationBranch from './branch'; import { BlockNavigationContext } from './context'; +import useBlockNavigationClientIds from './use-block-navigation-client-ids'; import useBlockNavigationDropZone from './use-block-navigation-drop-zone'; +import { store as blockEditorStore } from '../../store'; /** * Wrap `BlockNavigationRows` with `TreeGrid`. BlockNavigationRows is a * recursive component (it renders itself), so this ensures TreeGrid is only * present at the very top of the navigation grid. * - * @param {Object} props Components props. - * @param {boolean} props.__experimentalFeatures Flag to enable experimental features. - * @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment. + * @param {Object} props Components props. + * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy. + * @param {Function} props.onSelect Block selection callback. + * @param {Array} props.selectedBlockClientIds The client IDs of the (single or multi-) selected blocks. + * @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks. + * @param {boolean} props.showOnlyCurrentHierarchy Flag to limit the list to the current hierarchy of blocks. + * @param {boolean} props.__experimentalFeatures Flag to enable experimental features. + * @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment. */ export default function BlockNavigationTree( { + blocks, + showOnlyCurrentHierarchy, + onSelect = () => {}, + selectedBlockClientIds, __experimentalFeatures, __experimentalPersistentListViewFeatures, ...props } ) { + const { clientIdsTree, selectedClientIds } = useBlockNavigationClientIds( + blocks, + showOnlyCurrentHierarchy, + selectedBlockClientIds, + __experimentalPersistentListViewFeatures + ); + const { selectBlock } = useDispatch( blockEditorStore ); + function selectEditorBlock( clientId ) { + selectBlock( clientId ); + onSelect( clientId ); + } + let { ref: treeGridRef, target: blockDropTarget, @@ -62,7 +87,12 @@ export default function BlockNavigationTree( { ref={ treeGridRef } > - + ); diff --git a/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js b/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js new file mode 100644 index 0000000000000..e876106fb9b75 --- /dev/null +++ b/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js @@ -0,0 +1,78 @@ +/** + * WordPress dependencies + */ + +import { useSelect } from '@wordpress/data'; + +/** + * Internal dependencies + */ +import { isClientIdSelected } from './utils'; +import { store as blockEditorStore } from '../../store'; + +export default function useBlockNavigationClientIds( + blocks, + showOnlyCurrentHierarchy, + selectedBlockClientIds, + __experimentalPersistentListViewFeatures +) { + return useSelect( + ( select ) => { + const { + getBlockHierarchyRootClientId, + getSelectedBlockClientId, + getSelectedBlockClientIds, + __unstableGetClientIdsTree, + __unstableGetClientIdWithClientIdsTree, + } = select( blockEditorStore ); + + let selectedClientIds; + if ( selectedBlockClientIds ) { + selectedClientIds = selectedBlockClientIds; + } else if ( __experimentalPersistentListViewFeatures ) { + selectedClientIds = getSelectedBlockClientIds(); + } else { + selectedClientIds = getSelectedBlockClientId(); + } + + let clientIdsTree = blocks; + if ( blocks ) { + clientIdsTree = blocks; + } else if ( ! showOnlyCurrentHierarchy ) { + clientIdsTree = __unstableGetClientIdsTree(); + } else { + const rootBlock = + selectedClientIds && ! Array.isArray( selectedClientIds ) + ? __unstableGetClientIdWithClientIdsTree( + getBlockHierarchyRootClientId( + selectedClientIds + ) + ) + : null; + const hasHierarchy = + rootBlock && + ( ! isClientIdSelected( + rootBlock.clientId, + selectedClientIds + ) || + ( rootBlock.innerBlocks && + rootBlock.innerBlocks.length !== 0 ) ); + clientIdsTree = hasHierarchy + ? [ rootBlock ] + : __unstableGetClientIdsTree(); + } + + if ( ! Array.isArray( selectedClientIds ) ) { + selectedClientIds = [ selectedClientIds ]; + } + + return { clientIdsTree, selectedClientIds }; + }, + [ + blocks, + showOnlyCurrentHierarchy, + selectedBlockClientIds, + __experimentalPersistentListViewFeatures, + ] + ); +} diff --git a/packages/block-library/src/navigation/block-navigation-list.js b/packages/block-library/src/navigation/block-navigation-list.js index 057c4e6396b04..4b3f68470ed1d 100644 --- a/packages/block-library/src/navigation/block-navigation-list.js +++ b/packages/block-library/src/navigation/block-navigation-list.js @@ -5,38 +5,25 @@ import { __experimentalBlockNavigationTree, store as blockEditorStore, } from '@wordpress/block-editor'; -import { useSelect, useDispatch } from '@wordpress/data'; +import { useSelect } from '@wordpress/data'; export default function BlockNavigationList( { clientId, __experimentalFeatures, } ) { - const { blocks, selectedBlockClientId } = useSelect( - ( select ) => { - const { - getSelectedBlockClientId, - __unstableGetClientIdsTree, - } = select( blockEditorStore ); - - return { - blocks: __unstableGetClientIdsTree( clientId ), - selectedBlockClientId: getSelectedBlockClientId(), - }; - }, + const blocks = useSelect( + ( select ) => + select( blockEditorStore ).__unstableGetClientIdsTree( clientId ), [ clientId ] ); - const { selectBlock } = useDispatch( blockEditorStore ); - return ( <__experimentalBlockNavigationTree blocks={ blocks } - selectedBlockClientIds={ [ selectedBlockClientId ] } - selectBlock={ selectBlock } - __experimentalFeatures={ __experimentalFeatures } - showNestedBlocks showAppender showBlockMovers + showNestedBlocks + __experimentalFeatures={ __experimentalFeatures } /> ); } diff --git a/packages/edit-site/src/components/secondary-sidebar/list-view-sidebar.js b/packages/edit-site/src/components/secondary-sidebar/list-view-sidebar.js index 217a4bf192ffa..86bdf3bf05bb4 100644 --- a/packages/edit-site/src/components/secondary-sidebar/list-view-sidebar.js +++ b/packages/edit-site/src/components/secondary-sidebar/list-view-sidebar.js @@ -12,7 +12,7 @@ import { useInstanceId, useMergeRefs, } from '@wordpress/compose'; -import { useDispatch, useSelect } from '@wordpress/data'; +import { useDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { closeSmall } from '@wordpress/icons'; import { ESCAPE } from '@wordpress/keycodes'; @@ -23,16 +23,6 @@ import { ESCAPE } from '@wordpress/keycodes'; import { store as editSiteStore } from '../../store'; export default function ListViewSidebar() { - const { clientIdsTree, selectedBlockClientIds } = useSelect( ( select ) => { - const { - __unstableGetClientIdsTree, - getSelectedBlockClientIds, - } = select( blockEditorStore ); - return { - clientIdsTree: __unstableGetClientIdsTree(), - selectedBlockClientIds: getSelectedBlockClientIds(), - }; - }, [] ); const { setIsListViewOpened } = useDispatch( editSiteStore ); const { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore ); @@ -73,9 +63,7 @@ export default function ListViewSidebar() { ref={ useMergeRefs( [ focusReturnRef, focusOnMountRef ] ) } > From 6238fe00f0a4e70cf557a8212f3f00f52d92e072 Mon Sep 17 00:00:00 2001 From: Copons Date: Fri, 30 Apr 2021 15:26:16 +0100 Subject: [PATCH 2/7] Minor fixes --- .../src/components/block-navigation/index.js | 4 +++- .../src/components/block-navigation/tree.js | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/block-navigation/index.js b/packages/block-editor/src/components/block-navigation/index.js index ddee5b315f73d..656c3f8bed3c2 100644 --- a/packages/block-editor/src/components/block-navigation/index.js +++ b/packages/block-editor/src/components/block-navigation/index.js @@ -8,8 +8,10 @@ import { __ } from '@wordpress/i18n'; */ import BlockNavigationTree from './tree'; +const noop = () => {}; + export default function BlockNavigation( { - onSelect = () => {}, + onSelect = noop, __experimentalFeatures, } ) { return ( diff --git a/packages/block-editor/src/components/block-navigation/tree.js b/packages/block-editor/src/components/block-navigation/tree.js index ccb23a6dd0d76..65f798781364b 100644 --- a/packages/block-editor/src/components/block-navigation/tree.js +++ b/packages/block-editor/src/components/block-navigation/tree.js @@ -4,7 +4,7 @@ import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components'; import { useDispatch } from '@wordpress/data'; -import { useEffect, useMemo, useRef } from '@wordpress/element'; +import { useCallback, useEffect, useMemo, useRef } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; /** @@ -46,10 +46,13 @@ export default function BlockNavigationTree( { __experimentalPersistentListViewFeatures ); const { selectBlock } = useDispatch( blockEditorStore ); - function selectEditorBlock( clientId ) { - selectBlock( clientId ); - onSelect( clientId ); - } + const selectEditorBlock = useCallback( + ( clientId ) => { + selectBlock( clientId ); + onSelect( clientId ); + }, + [ selectBlock, onSelect ] + ); let { ref: treeGridRef, From 6f963747b937a887b872871da026d8896870216c Mon Sep 17 00:00:00 2001 From: Copons Date: Fri, 30 Apr 2021 15:26:39 +0100 Subject: [PATCH 3/7] Restructure useBlockNavigationClientIds hook for readability --- .../use-block-navigation-client-ids.js | 111 ++++++++++-------- 1 file changed, 64 insertions(+), 47 deletions(-) diff --git a/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js b/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js index e876106fb9b75..e854ad99d9fac 100644 --- a/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js +++ b/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js @@ -10,69 +10,86 @@ import { useSelect } from '@wordpress/data'; import { isClientIdSelected } from './utils'; import { store as blockEditorStore } from '../../store'; -export default function useBlockNavigationClientIds( - blocks, - showOnlyCurrentHierarchy, +const useBlockNavigationSelectedClientIds = ( selectedBlockClientIds, __experimentalPersistentListViewFeatures -) { - return useSelect( +) => + useSelect( ( select ) => { const { - getBlockHierarchyRootClientId, getSelectedBlockClientId, getSelectedBlockClientIds, - __unstableGetClientIdsTree, - __unstableGetClientIdWithClientIdsTree, } = select( blockEditorStore ); - let selectedClientIds; if ( selectedBlockClientIds ) { - selectedClientIds = selectedBlockClientIds; - } else if ( __experimentalPersistentListViewFeatures ) { - selectedClientIds = getSelectedBlockClientIds(); - } else { - selectedClientIds = getSelectedBlockClientId(); + return selectedBlockClientIds; + } + + if ( __experimentalPersistentListViewFeatures ) { + return getSelectedBlockClientIds(); } - let clientIdsTree = blocks; + return getSelectedBlockClientId(); + }, + [ selectedBlockClientIds, __experimentalPersistentListViewFeatures ] + ); + +const useBlockNavigationClientIdsTree = ( + blocks, + selectedClientIds, + showOnlyCurrentHierarchy +) => + useSelect( + ( select ) => { + const { + getBlockHierarchyRootClientId, + __unstableGetClientIdsTree, + __unstableGetClientIdWithClientIdsTree, + } = select( blockEditorStore ); + if ( blocks ) { - clientIdsTree = blocks; - } else if ( ! showOnlyCurrentHierarchy ) { - clientIdsTree = __unstableGetClientIdsTree(); - } else { - const rootBlock = - selectedClientIds && ! Array.isArray( selectedClientIds ) - ? __unstableGetClientIdWithClientIdsTree( - getBlockHierarchyRootClientId( - selectedClientIds - ) - ) - : null; - const hasHierarchy = - rootBlock && - ( ! isClientIdSelected( - rootBlock.clientId, - selectedClientIds - ) || - ( rootBlock.innerBlocks && - rootBlock.innerBlocks.length !== 0 ) ); - clientIdsTree = hasHierarchy - ? [ rootBlock ] - : __unstableGetClientIdsTree(); + return blocks; + } + + const isSingleBlockSelected = + selectedClientIds && ! Array.isArray( selectedClientIds ); + if ( ! showOnlyCurrentHierarchy || ! isSingleBlockSelected ) { + return __unstableGetClientIdsTree(); + } + + const rootBlock = __unstableGetClientIdWithClientIdsTree( + getBlockHierarchyRootClientId( selectedClientIds ) + ); + if ( ! rootBlock ) { + return __unstableGetClientIdsTree(); } - if ( ! Array.isArray( selectedClientIds ) ) { - selectedClientIds = [ selectedClientIds ]; + const hasHierarchy = + ! isClientIdSelected( rootBlock.clientId, selectedClientIds ) || + ( rootBlock.innerBlocks && rootBlock.innerBlocks.length !== 0 ); + if ( hasHierarchy ) { + return [ rootBlock ]; } - return { clientIdsTree, selectedClientIds }; + return __unstableGetClientIdsTree(); }, - [ - blocks, - showOnlyCurrentHierarchy, - selectedBlockClientIds, - __experimentalPersistentListViewFeatures, - ] + [ blocks, selectedClientIds, showOnlyCurrentHierarchy ] + ); + +export default function useBlockNavigationClientIds( + blocks, + showOnlyCurrentHierarchy, + selectedBlockClientIds, + __experimentalPersistentListViewFeatures +) { + const selectedClientIds = useBlockNavigationSelectedClientIds( + selectedBlockClientIds, + __experimentalPersistentListViewFeatures + ); + const clientIdsTree = useBlockNavigationClientIdsTree( + blocks, + selectedClientIds, + showOnlyCurrentHierarchy ); + return { clientIdsTree, selectedClientIds }; } From 06a0d01be416bc5e3f23b4f697f0d53bc4fea442 Mon Sep 17 00:00:00 2001 From: Copons Date: Tue, 11 May 2021 14:32:17 +0100 Subject: [PATCH 4/7] Move noop to const --- packages/block-editor/src/components/block-navigation/tree.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/block-navigation/tree.js b/packages/block-editor/src/components/block-navigation/tree.js index 65f798781364b..0931c667f8612 100644 --- a/packages/block-editor/src/components/block-navigation/tree.js +++ b/packages/block-editor/src/components/block-navigation/tree.js @@ -16,6 +16,8 @@ import useBlockNavigationClientIds from './use-block-navigation-client-ids'; import useBlockNavigationDropZone from './use-block-navigation-drop-zone'; import { store as blockEditorStore } from '../../store'; +const noop = () => {}; + /** * Wrap `BlockNavigationRows` with `TreeGrid`. BlockNavigationRows is a * recursive component (it renders itself), so this ensures TreeGrid is only @@ -33,7 +35,7 @@ import { store as blockEditorStore } from '../../store'; export default function BlockNavigationTree( { blocks, showOnlyCurrentHierarchy, - onSelect = () => {}, + onSelect = noop, selectedBlockClientIds, __experimentalFeatures, __experimentalPersistentListViewFeatures, From 91acff1f7bb0434cc7b682cf25ff92df265b96e2 Mon Sep 17 00:00:00 2001 From: Copons Date: Mon, 17 May 2021 14:39:39 +0100 Subject: [PATCH 5/7] Simplify post editor list view --- .../secondary-sidebar/list-view-sidebar.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/packages/edit-post/src/components/secondary-sidebar/list-view-sidebar.js b/packages/edit-post/src/components/secondary-sidebar/list-view-sidebar.js index 332ba89857358..d7947e437c4c5 100644 --- a/packages/edit-post/src/components/secondary-sidebar/list-view-sidebar.js +++ b/packages/edit-post/src/components/secondary-sidebar/list-view-sidebar.js @@ -12,7 +12,7 @@ import { useInstanceId, useMergeRefs, } from '@wordpress/compose'; -import { useDispatch, useSelect } from '@wordpress/data'; +import { useDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { closeSmall } from '@wordpress/icons'; import { ESCAPE } from '@wordpress/keycodes'; @@ -23,16 +23,6 @@ import { ESCAPE } from '@wordpress/keycodes'; import { store as editPostStore } from '../../store'; export default function ListViewSidebar() { - const { clientIdsTree, selectedBlockClientIds } = useSelect( ( select ) => { - const { - __unstableGetClientIdsTree, - getSelectedBlockClientIds, - } = select( blockEditorStore ); - return { - clientIdsTree: __unstableGetClientIdsTree(), - selectedBlockClientIds: getSelectedBlockClientIds(), - }; - }, [] ); const { setIsListViewOpened } = useDispatch( editPostStore ); const { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore ); @@ -73,9 +63,7 @@ export default function ListViewSidebar() { ref={ useMergeRefs( [ focusReturnRef, focusOnMountRef ] ) } > From ef1b5fab5b156b3aa61ecf7d55ef02022b94626a Mon Sep 17 00:00:00 2001 From: Copons Date: Mon, 17 May 2021 14:48:25 +0100 Subject: [PATCH 6/7] Remove the BlockNavigation component as it's not currently used anymore --- .../components/block-navigation/dropdown.js | 16 +++++++--- .../src/components/block-navigation/index.js | 31 ------------------- 2 files changed, 12 insertions(+), 35 deletions(-) delete mode 100644 packages/block-editor/src/components/block-navigation/index.js diff --git a/packages/block-editor/src/components/block-navigation/dropdown.js b/packages/block-editor/src/components/block-navigation/dropdown.js index bb3fd2eb453dd..de7345280387a 100644 --- a/packages/block-editor/src/components/block-navigation/dropdown.js +++ b/packages/block-editor/src/components/block-navigation/dropdown.js @@ -10,7 +10,7 @@ import { listView } from '@wordpress/icons'; /** * Internal dependencies */ -import BlockNavigation from './'; +import BlockNavigationTree from './tree'; import { store as blockEditorStore } from '../../store'; function BlockNavigationDropdownToggle( { @@ -60,9 +60,17 @@ function BlockNavigationDropdown( /> ) } renderContent={ () => ( - +
+

+ { __( 'List view' ) } +

+ + +
) } /> ); diff --git a/packages/block-editor/src/components/block-navigation/index.js b/packages/block-editor/src/components/block-navigation/index.js deleted file mode 100644 index 656c3f8bed3c2..0000000000000 --- a/packages/block-editor/src/components/block-navigation/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import BlockNavigationTree from './tree'; - -const noop = () => {}; - -export default function BlockNavigation( { - onSelect = noop, - __experimentalFeatures, -} ) { - return ( -
-

- { __( 'List view' ) } -

- - -
- ); -} From 757f20b2ebf8010ed7625e112e934c1a829fa003 Mon Sep 17 00:00:00 2001 From: Copons Date: Thu, 20 May 2021 16:38:54 +0100 Subject: [PATCH 7/7] Remove unnecessary selectedClientIds prop in hooks --- .../block-editor/src/components/block-navigation/tree.js | 3 --- .../block-navigation/use-block-navigation-client-ids.js | 9 +-------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/packages/block-editor/src/components/block-navigation/tree.js b/packages/block-editor/src/components/block-navigation/tree.js index 0931c667f8612..f8e64233935b6 100644 --- a/packages/block-editor/src/components/block-navigation/tree.js +++ b/packages/block-editor/src/components/block-navigation/tree.js @@ -26,7 +26,6 @@ const noop = () => {}; * @param {Object} props Components props. * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy. * @param {Function} props.onSelect Block selection callback. - * @param {Array} props.selectedBlockClientIds The client IDs of the (single or multi-) selected blocks. * @param {boolean} props.showNestedBlocks Flag to enable displaying nested blocks. * @param {boolean} props.showOnlyCurrentHierarchy Flag to limit the list to the current hierarchy of blocks. * @param {boolean} props.__experimentalFeatures Flag to enable experimental features. @@ -36,7 +35,6 @@ export default function BlockNavigationTree( { blocks, showOnlyCurrentHierarchy, onSelect = noop, - selectedBlockClientIds, __experimentalFeatures, __experimentalPersistentListViewFeatures, ...props @@ -44,7 +42,6 @@ export default function BlockNavigationTree( { const { clientIdsTree, selectedClientIds } = useBlockNavigationClientIds( blocks, showOnlyCurrentHierarchy, - selectedBlockClientIds, __experimentalPersistentListViewFeatures ); const { selectBlock } = useDispatch( blockEditorStore ); diff --git a/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js b/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js index e854ad99d9fac..e68cadf582de8 100644 --- a/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js +++ b/packages/block-editor/src/components/block-navigation/use-block-navigation-client-ids.js @@ -11,7 +11,6 @@ import { isClientIdSelected } from './utils'; import { store as blockEditorStore } from '../../store'; const useBlockNavigationSelectedClientIds = ( - selectedBlockClientIds, __experimentalPersistentListViewFeatures ) => useSelect( @@ -21,17 +20,13 @@ const useBlockNavigationSelectedClientIds = ( getSelectedBlockClientIds, } = select( blockEditorStore ); - if ( selectedBlockClientIds ) { - return selectedBlockClientIds; - } - if ( __experimentalPersistentListViewFeatures ) { return getSelectedBlockClientIds(); } return getSelectedBlockClientId(); }, - [ selectedBlockClientIds, __experimentalPersistentListViewFeatures ] + [ __experimentalPersistentListViewFeatures ] ); const useBlockNavigationClientIdsTree = ( @@ -79,11 +74,9 @@ const useBlockNavigationClientIdsTree = ( export default function useBlockNavigationClientIds( blocks, showOnlyCurrentHierarchy, - selectedBlockClientIds, __experimentalPersistentListViewFeatures ) { const selectedClientIds = useBlockNavigationSelectedClientIds( - selectedBlockClientIds, __experimentalPersistentListViewFeatures ); const clientIdsTree = useBlockNavigationClientIdsTree(