Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions packages/block-editor/src/components/block-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
useCallback,
useEffect,
} from '@wordpress/element';
import { getDefaultBlockName } from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -171,13 +172,13 @@ function Items( {
const {
getSettings,
getBlockOrder,
getSelectedBlockClientId,
getSelectedBlockClientIds,
__unstableGetVisibleBlocks,
getTemplateLock,
getBlockEditingMode,
isSectionBlock,
isZoomOut: _isZoomOut,
canInsertBlockType,
} = unlock( select( blockEditorStore ) );

const _order = getBlockOrder( rootClientId );
Expand All @@ -190,10 +191,20 @@ function Items( {
};
}

const selectedBlockClientId = getSelectedBlockClientId();
const selectedBlockClientIds = getSelectedBlockClientIds();
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
const showRootAppender =
! rootClientId &&
! selectedBlockClientId &&
( ! _order.length ||
! canInsertBlockType(
getDefaultBlockName(),
rootClientId
) );
Comment on lines +200 to +203
Copy link
Member Author

Choose a reason for hiding this comment

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

A micro-optimization avoids unnecessarily calling the selector.


return {
order: _order,
selectedBlocks: getSelectedBlockClientIds(),
selectedBlocks: selectedBlockClientIds,
visibleBlocks: __unstableGetVisibleBlocks(),
isZoomOut: _isZoomOut(),
shouldRenderAppender:
Expand All @@ -203,10 +214,8 @@ function Items( {
hasAppender &&
! _isZoomOut() &&
( hasCustomAppender ||
rootClientId === selectedBlockClientId ||
( ! rootClientId &&
! selectedBlockClientId &&
! _order.length ) ),
showRootAppender ||
rootClientId === selectedBlockClientId ),
};
},
[ rootClientId, hasAppender, hasCustomAppender ]
Expand Down
Loading