From e3d5b7a7e0570f1134b3bddd59cd743c3e5b60c1 Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Wed, 23 Oct 2024 12:30:45 +0200 Subject: [PATCH] Disable block gap rendering between root-level blocks. Top level blocks are post content and header and footer wrapping blocks. Disabling the gap between these blocks prevents rendering a gap between post-content blocks and header and footer. [MAILPOET-6088] --- .../block-editor/visual-editor/visual-editor.tsx | 1 - .../Preprocessors/SpacingPreprocessor.php | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mailpoet/assets/js/src/email-editor/engine/components/block-editor/visual-editor/visual-editor.tsx b/mailpoet/assets/js/src/email-editor/engine/components/block-editor/visual-editor/visual-editor.tsx index 1d064b8e13..0199358574 100644 --- a/mailpoet/assets/js/src/email-editor/engine/components/block-editor/visual-editor/visual-editor.tsx +++ b/mailpoet/assets/js/src/email-editor/engine/components/block-editor/visual-editor/visual-editor.tsx @@ -176,7 +176,6 @@ export function VisualEditor({ $block) { $parentBlockName = $parentBlock['blockName'] ?? ''; - // Do not add a gap to the first child, or if the parent block is a buttons block (where buttons are side by side). - if ($key !== 0 && $gap && $parentBlockName !== 'core/buttons') { + /** + * Do not add a gap to: + * - the top level blocks - they are post-content, and header and footer wrappers and we don't want a gap between those + * - first child + * - parent block is a buttons block (where buttons are side by side). + **/ + if ($parentBlock && $key !== 0 && $gap && $parentBlockName !== 'core/buttons') { $block['email_attrs']['margin-top'] = $gap; }