diff --git a/packages/block-editor/src/components/list-view/branch.js b/packages/block-editor/src/components/list-view/branch.js index 108cdf55412962..ebd1d5a36f5700 100644 --- a/packages/block-editor/src/components/list-view/branch.js +++ b/packages/block-editor/src/components/list-view/branch.js @@ -121,8 +121,6 @@ function ListViewBranch( props ) { blockIndexes, expandedState, draggedClientIds, - sectionBlockClientIds, - isZoomOutMode, } = useListViewContext(); if ( ! canParentExpand ) { @@ -176,14 +174,8 @@ function ListViewBranch( props ) { : `${ position }`; const hasNestedBlocks = !! innerBlocks?.length; - const isZoomOutSectionBlock = - isZoomOutMode && - sectionBlockClientIds?.includes( clientId ); - const shouldExpand = - ! isZoomOutSectionBlock && - hasNestedBlocks && - shouldShowInnerBlocks + hasNestedBlocks && shouldShowInnerBlocks ? expandedState[ clientId ] ?? isExpanded : undefined; diff --git a/packages/block-editor/src/components/list-view/index.js b/packages/block-editor/src/components/list-view/index.js index 1b545fc9514280..1493fa655a5aac 100644 --- a/packages/block-editor/src/components/list-view/index.js +++ b/packages/block-editor/src/components/list-view/index.js @@ -45,8 +45,6 @@ import { BlockSettingsDropdown } from '../block-settings-menu/block-settings-dro import { focusListItem } from './utils'; import useClipboardHandler from './use-clipboard-handler'; -import { unlock } from '../../lock-unlock'; - const expanded = ( state, action ) => { if ( action.type === 'clear' ) { return {}; @@ -121,36 +119,24 @@ function ListViewComponent( const blockIndexes = useListViewBlockIndexes( clientIdsTree ); const { getBlock } = useSelect( blockEditorStore ); - - const { sectionBlockClientIds, isZoomOutMode, visibleBlockCount } = - useSelect( - ( select ) => { - const { - getGlobalBlockCount, - getClientIdsOfDescendants, - __unstableGetEditorMode, - getSectionRootClientId, - getBlockOrder, - } = unlock( select( blockEditorStore ) ); - const draggedBlockCount = - draggedClientIds?.length > 0 - ? getClientIdsOfDescendants( draggedClientIds ).length + - 1 - : 0; - - const _isZoomOutMode = __unstableGetEditorMode() === 'zoom-out'; - - return { - visibleBlockCount: - getGlobalBlockCount() - draggedBlockCount, - sectionBlockClientIds: getBlockOrder( - getSectionRootClientId() - ), - isZoomOutMode: _isZoomOutMode, - }; - }, - [ draggedClientIds ] - ); + const { visibleBlockCount, shouldShowInnerBlocks } = useSelect( + ( select ) => { + const { + getGlobalBlockCount, + getClientIdsOfDescendants, + __unstableGetEditorMode, + } = select( blockEditorStore ); + const draggedBlockCount = + draggedClientIds?.length > 0 + ? getClientIdsOfDescendants( draggedClientIds ).length + 1 + : 0; + return { + visibleBlockCount: getGlobalBlockCount() - draggedBlockCount, + shouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out', + }; + }, + [ draggedClientIds ] + ); const { updateBlockSelection } = useBlockSelection(); @@ -319,8 +305,6 @@ function ListViewComponent( setInsertedBlock, treeGridElementRef: elementRef, rootClientId, - sectionBlockClientIds, - isZoomOutMode, } ), [ blockDropPosition, @@ -338,8 +322,6 @@ function ListViewComponent( insertedBlock, setInsertedBlock, rootClientId, - sectionBlockClientIds, - isZoomOutMode, ] ); @@ -415,6 +397,7 @@ function ListViewComponent( fixedListWindow={ fixedListWindow } selectedClientIds={ selectedClientIds } isExpanded={ isExpanded } + shouldShowInnerBlocks={ shouldShowInnerBlocks } showAppender={ showAppender } />