From 1cad22d18f1df307b44fc3b0bc2c40e36fce8b13 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Mon, 6 Jul 2026 18:57:17 -0400 Subject: [PATCH] Fix max-width block save shape --- .../src/HtmlToBlocks/Style/StyleAttributeMapper.php | 6 +++--- .../tests/unit/block-style-support-conversion.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/php-transformer/src/HtmlToBlocks/Style/StyleAttributeMapper.php b/php-transformer/src/HtmlToBlocks/Style/StyleAttributeMapper.php index d812d0d1..ace96b4f 100644 --- a/php-transformer/src/HtmlToBlocks/Style/StyleAttributeMapper.php +++ b/php-transformer/src/HtmlToBlocks/Style/StyleAttributeMapper.php @@ -188,9 +188,9 @@ public function serialize(array $style): array if ( '' !== trim((string) ($dimensions['minHeight'] ?? '')) ) { $declarations[] = 'min-height:' . trim((string) $dimensions['minHeight']); } - if ( '' !== trim((string) ($dimensions['maxWidth'] ?? '')) ) { - $declarations[] = 'max-width:' . trim((string) $dimensions['maxWidth']); - } + // Core stores dimensions.maxWidth in block attrs but does not reproduce + // it as an inline wrapper declaration in save(), so emitting it here + // makes otherwise native blocks fail editor validation. $typography = is_array($style['typography'] ?? null) ? $style['typography'] : array(); $typographyMap = array( diff --git a/php-transformer/tests/unit/block-style-support-conversion.php b/php-transformer/tests/unit/block-style-support-conversion.php index 2c4a15e8..a90c1ff6 100644 --- a/php-transformer/tests/unit/block-style-support-conversion.php +++ b/php-transformer/tests/unit/block-style-support-conversion.php @@ -66,8 +66,8 @@ $assert('1120px' === ($cardShellAttrs['style']['dimensions']['maxWidth'] ?? ''), '17: section max-width maps to dimensions support', json_encode($cardShellAttrs['style']['dimensions'] ?? array())); $assert('360px' === ($cardAttrs['style']['dimensions']['maxWidth'] ?? ''), '18: card max-width maps to dimensions support', json_encode($cardAttrs['style']['dimensions'] ?? array())); -$assert(str_contains($cardMarkup, 'max-width:1120px'), '19: rendered section preserves max-width geometry', $cardMarkup); -$assert(str_contains($cardMarkup, 'max-width:360px'), '20: rendered card preserves max-width geometry', $cardMarkup); +$assert(! str_contains($cardMarkup, 'max-width:1120px'), '19: rendered section omits max-width that core save() does not reproduce', $cardMarkup); +$assert(! str_contains($cardMarkup, 'max-width:360px'), '20: rendered card omits max-width that core save() does not reproduce', $cardMarkup); $assert(! str_contains($cardMarkup, 'style="max-width:1120px;margin:0 auto;padding:5rem 2rem"'), '21: rendered section does not keep unsupported raw style wholesale', $cardMarkup); $labelHtml = '
Pricing

Simple plans

Team
$29/mo
Launch faster
';