Skip to content

Commit

Permalink
Block Editor: Display root appender when default block is disabled (W…
Browse files Browse the repository at this point in the history
…ordPress#68951)

* Block Editor: Display root appender when default block is disabled
* Handle multi-selection

Unlinked contributors: virgiliud, MGabrane, alexis-magina, sweco-seerjf.

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2025
1 parent eab1a3b commit 055f881
Showing 1 changed file with 16 additions and 7 deletions.
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
) );

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

0 comments on commit 055f881

Please sign in to comment.