Skip to content

Commit fcf0b5d

Browse files
authored
Block editor: prevent isSubtreeDisabled call if not needed (#58349)
1 parent 0bb25ed commit fcf0b5d

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

packages/block-editor/src/components/block-list/block.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ function BlockListBlockProvider( props ) {
555555
const typing = isTyping();
556556
const hasLightBlockWrapper = blockType?.apiVersion > 1;
557557
const movingClientId = hasBlockMovingClientId();
558-
558+
const blockEditingMode = getBlockEditingMode( clientId );
559559
return {
560560
mode: getBlockMode( clientId ),
561561
isSelectionEnabled: isSelectionEnabled(),
@@ -574,7 +574,7 @@ function BlockListBlockProvider( props ) {
574574
themeSupportsLayout: supportsLayout,
575575
isTemporarilyEditingAsBlocks:
576576
__unstableGetTemporarilyEditingAsBlocks() === clientId,
577-
blockEditingMode: getBlockEditingMode( clientId ),
577+
blockEditingMode,
578578
mayDisplayControls:
579579
_isSelected ||
580580
( isFirstMultiSelectedBlock( clientId ) &&
@@ -590,7 +590,9 @@ function BlockListBlockProvider( props ) {
590590
index: getBlockIndex( clientId ),
591591
blockApiVersion: blockType?.apiVersion || 1,
592592
blockTitle: match?.title || blockType?.title,
593-
isSubtreeDisabled: isBlockSubtreeDisabled( clientId ),
593+
isSubtreeDisabled:
594+
blockEditingMode === 'disabled' &&
595+
isBlockSubtreeDisabled( clientId ),
594596
isOutlineEnabled: outlineMode,
595597
hasOverlay: __unstableHasActiveBlockOverlayActive( clientId ),
596598
initialPosition:
@@ -614,8 +616,7 @@ function BlockListBlockProvider( props ) {
614616
getBlockName( movingClientId ),
615617
getBlockRootClientId( clientId )
616618
),
617-
isEditingDisabled:
618-
getBlockEditingMode( clientId ) === 'disabled',
619+
isEditingDisabled: blockEditingMode === 'disabled',
619620
className: hasLightBlockWrapper
620621
? attributes.className
621622
: undefined,

packages/block-editor/src/store/private-selectors.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ export function getLastInsertedBlocksClientIds( state ) {
4545
}
4646

4747
/**
48-
* Returns true if the block with the given client ID and all of its descendants
48+
* Returns true if all of the descendants of a block with the given client ID
4949
* have an editing mode of 'disabled', or false otherwise.
5050
*
5151
* @param {Object} state Global application state.
5252
* @param {string} clientId The block client ID.
5353
*
54-
* @return {boolean} Whether the block and its descendants are disabled.
54+
* @return {boolean} Whether the block descendants are disabled.
5555
*/
5656
export const isBlockSubtreeDisabled = createSelector(
5757
( state, clientId ) => {
@@ -63,10 +63,7 @@ export const isBlockSubtreeDisabled = createSelector(
6363
)
6464
);
6565
};
66-
return (
67-
getBlockEditingMode( state, clientId ) === 'disabled' &&
68-
getBlockOrder( state, clientId ).every( isChildSubtreeDisabled )
69-
);
66+
return getBlockOrder( state, clientId ).every( isChildSubtreeDisabled );
7067
},
7168
( state ) => [
7269
state.blocks.parents,

0 commit comments

Comments
 (0)