Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ function BlockListBlockProvider( props ) {
const typing = isTyping();
const hasLightBlockWrapper = blockType?.apiVersion > 1;
const movingClientId = hasBlockMovingClientId();

const blockEditingMode = getBlockEditingMode( clientId );
return {
mode: getBlockMode( clientId ),
isSelectionEnabled: isSelectionEnabled(),
Expand All @@ -574,7 +574,7 @@ function BlockListBlockProvider( props ) {
themeSupportsLayout: supportsLayout,
isTemporarilyEditingAsBlocks:
__unstableGetTemporarilyEditingAsBlocks() === clientId,
blockEditingMode: getBlockEditingMode( clientId ),
blockEditingMode,
mayDisplayControls:
_isSelected ||
( isFirstMultiSelectedBlock( clientId ) &&
Expand All @@ -590,7 +590,9 @@ function BlockListBlockProvider( props ) {
index: getBlockIndex( clientId ),
blockApiVersion: blockType?.apiVersion || 1,
blockTitle: match?.title || blockType?.title,
isSubtreeDisabled: isBlockSubtreeDisabled( clientId ),
isSubtreeDisabled:
blockEditingMode === 'disabled' &&
isBlockSubtreeDisabled( clientId ),
Copy link
Member Author

Choose a reason for hiding this comment

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

Prevents isBlockSubtreeDisabled from calling getBlockEditingMode again.

isOutlineEnabled: outlineMode,
hasOverlay: __unstableHasActiveBlockOverlayActive( clientId ),
initialPosition:
Expand All @@ -614,8 +616,7 @@ function BlockListBlockProvider( props ) {
getBlockName( movingClientId ),
getBlockRootClientId( clientId )
),
isEditingDisabled:
getBlockEditingMode( clientId ) === 'disabled',
isEditingDisabled: blockEditingMode === 'disabled',
className: hasLightBlockWrapper
? attributes.className
: undefined,
Expand Down
9 changes: 3 additions & 6 deletions packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ export function getLastInsertedBlocksClientIds( state ) {
}

/**
* Returns true if the block with the given client ID and all of its descendants
* Returns true if all of the descendants of a block with the given client ID
* have an editing mode of 'disabled', or false otherwise.
*
* @param {Object} state Global application state.
* @param {string} clientId The block client ID.
*
* @return {boolean} Whether the block and its descendants are disabled.
* @return {boolean} Whether the block descendants are disabled.
*/
export const isBlockSubtreeDisabled = createSelector(
( state, clientId ) => {
Expand All @@ -63,10 +63,7 @@ export const isBlockSubtreeDisabled = createSelector(
)
);
};
return (
getBlockEditingMode( state, clientId ) === 'disabled' &&
getBlockOrder( state, clientId ).every( isChildSubtreeDisabled )
);
return getBlockOrder( state, clientId ).every( isChildSubtreeDisabled );
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this is a private selector, so we can change it. There's also only one used case which is the above.

},
( state ) => [
state.blocks.parents,
Expand Down