From a988b90e855211f9094a1c2abe3218bb6ea8d61c Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Thu, 15 Feb 2024 19:49:43 +1300 Subject: [PATCH] Patterns: Check we are not within a pattern instance before running block deletion rules (#59044) * Check we are not within a pattern instance before running block deletion rules on overridden blocks * Make comment more explanatory Co-authored-by: glendaviesnz Co-authored-by: talldan --- 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 d1db598c8c8e65..ae0a06152fb933 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' + ); + // We only need to run this check when editing the original pattern, not pattern instances. + if ( parentPatternBlocks?.length > 0 ) { + continue; + } const blockAttributes = select.getBlockAttributes( clientId ); if (