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
25 changes: 22 additions & 3 deletions packages/block-editor/src/components/block-list-appender/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function BlockListAppender( {
isLocked,
renderAppender: CustomAppender,
className,
selectedBlockClientId,
tagName: TagName = 'div',
} ) {
if ( isLocked || CustomAppender === false ) {
Expand All @@ -40,6 +41,20 @@ function BlockListAppender( {
} else if ( canInsertDefaultBlock ) {
// Render the default block appender when renderAppender has not been
// provided and the context supports use of the default appender.
const isDocumentAppender = ! rootClientId;
const isParentSelected = selectedBlockClientId === rootClientId;
const isAnotherDefaultAppenderAlreadyDisplayed =
selectedBlockClientId &&
! blockClientIds.includes( selectedBlockClientId );

if (
! isDocumentAppender &&
! isParentSelected &&
isAnotherDefaultAppenderAlreadyDisplayed
) {
return null;
}

appender = (
<DefaultBlockAppender
rootClientId={ rootClientId }
Expand Down Expand Up @@ -79,9 +94,12 @@ function BlockListAppender( {
}

export default withSelect( ( select, { rootClientId } ) => {
const { getBlockOrder, canInsertBlockType, getTemplateLock } = select(
'core/block-editor'
);
const {
getBlockOrder,
canInsertBlockType,
getTemplateLock,
getSelectedBlockClientId,
} = select( 'core/block-editor' );

return {
isLocked: !! getTemplateLock( rootClientId ),
Expand All @@ -90,5 +108,6 @@ export default withSelect( ( select, { rootClientId } ) => {
getDefaultBlockName(),
rootClientId
),
selectedBlockClientId: getSelectedBlockClientId(),
};
} )( BlockListAppender );