From f1954d343a549f003c3e4be4383eb7ed68362ca7 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Wed, 18 Sep 2024 17:23:48 +0100 Subject: [PATCH] Blocks within sections shouldn't be removable --- packages/block-editor/src/store/selectors.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index 1c3bf28ab082d..ca66340a89e30 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -39,6 +39,7 @@ import { getTemporarilyEditingFocusModeToRevert, getSectionRootClientId, isSectionBlock, + getParentSectionBlock, } from './private-selectors'; /** @@ -1739,6 +1740,11 @@ export function canRemoveBlock( state, clientId ) { return false; } + const isBlockWithinSection = !! getParentSectionBlock( state, clientId ); + if ( isBlockWithinSection ) { + return false; + } + return getBlockEditingMode( state, rootClientId ) !== 'disabled'; }