Skip to content

Commit

Permalink
Revert initial changes
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Sep 11, 2024
1 parent 98ba5ff commit 3fb66f4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 45 deletions.
10 changes: 1 addition & 9 deletions packages/block-editor/src/components/list-view/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ function ListViewBranch( props ) {
blockIndexes,
expandedState,
draggedClientIds,
sectionBlockClientIds,
isZoomOutMode,
} = useListViewContext();

if ( ! canParentExpand ) {
Expand Down Expand Up @@ -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;

Expand Down
55 changes: 19 additions & 36 deletions packages/block-editor/src/components/list-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -319,8 +305,6 @@ function ListViewComponent(
setInsertedBlock,
treeGridElementRef: elementRef,
rootClientId,
sectionBlockClientIds,
isZoomOutMode,
} ),
[
blockDropPosition,
Expand All @@ -338,8 +322,6 @@ function ListViewComponent(
insertedBlock,
setInsertedBlock,
rootClientId,
sectionBlockClientIds,
isZoomOutMode,
]
);

Expand Down Expand Up @@ -415,6 +397,7 @@ function ListViewComponent(
fixedListWindow={ fixedListWindow }
selectedClientIds={ selectedClientIds }
isExpanded={ isExpanded }
shouldShowInnerBlocks={ shouldShowInnerBlocks }
showAppender={ showAppender }
/>
</ListViewContext.Provider>
Expand Down

0 comments on commit 3fb66f4

Please sign in to comment.