From 114537b815bbd080e9a3f72a3d392d5fa27602b8 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Thu, 15 Feb 2024 12:53:18 +1300 Subject: [PATCH 1/2] Check we are not within a pattern instance before running block deletion rules on overridden blocks --- packages/block-editor/src/store/private-actions.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/block-editor/src/store/private-actions.js b/packages/block-editor/src/store/private-actions.js index d1db598c8c8e6..4ee1b89db7e2d 100644 --- a/packages/block-editor/src/store/private-actions.js +++ b/packages/block-editor/src/store/private-actions.js @@ -140,6 +140,15 @@ export const privateRemoveBlocks = } if ( rules[ 'bindings/core/pattern-overrides' ] ) { + const parentPatternBlocks = + select.getBlockParentsByBlockName( + clientId, + 'core/block' + ); + // If the overriden block is a child of a core/block, skip it. + if ( parentPatternBlocks?.length > 0 ) { + continue; + } const blockAttributes = select.getBlockAttributes( clientId ); if ( From 72b5b6bd03188bf65f46ba0c205fc9e1a307acba Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Thu, 15 Feb 2024 13:12:51 +1300 Subject: [PATCH 2/2] Make comment more explanatory --- packages/block-editor/src/store/private-actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/store/private-actions.js b/packages/block-editor/src/store/private-actions.js index 4ee1b89db7e2d..ae0a06152fb93 100644 --- a/packages/block-editor/src/store/private-actions.js +++ b/packages/block-editor/src/store/private-actions.js @@ -145,7 +145,7 @@ export const privateRemoveBlocks = clientId, 'core/block' ); - // If the overriden block is a child of a core/block, skip it. + // We only need to run this check when editing the original pattern, not pattern instances. if ( parentPatternBlocks?.length > 0 ) { continue; }