diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index f70e1cae176dd4..350d158cd6e24f 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -45,16 +45,7 @@ function gutenberg_get_layout_definitions() { ), ), ), - // First/last child rules need to be after `> *` rule to take - // precedence when they have the same specificity. 'spacingStyles' => array( - array( - 'selector' => ' > *', - 'rules' => array( - 'margin-block-start' => null, - 'margin-block-end' => '0', - ), - ), array( 'selector' => ' > :first-child', 'rules' => array( @@ -67,6 +58,13 @@ function gutenberg_get_layout_definitions() { 'margin-block-end' => '0', ), ), + array( + 'selector' => ' > *', + 'rules' => array( + 'margin-block-start' => null, + 'margin-block-end' => '0', + ), + ), ), ), 'constrained' => array( @@ -112,16 +110,7 @@ function gutenberg_get_layout_definitions() { ), ), ), - // First/last child rules need to be after `> *` rule to take - // precedence when they have the same specificity. 'spacingStyles' => array( - array( - 'selector' => ' > *', - 'rules' => array( - 'margin-block-start' => null, - 'margin-block-end' => '0', - ), - ), array( 'selector' => ' > :first-child', 'rules' => array( @@ -134,6 +123,13 @@ function gutenberg_get_layout_definitions() { 'margin-block-end' => '0', ), ), + array( + 'selector' => ' > *', + 'rules' => array( + 'margin-block-start' => null, + 'margin-block-end' => '0', + ), + ), ), ), 'flex' => array( diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 34c44efe3efd14..63e446be9c1c67 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -1724,7 +1724,7 @@ protected function get_layout_styles( $block_metadata, $types = array() ) { $spacing_rule['selector'] ); } else { - $format = static::ROOT_BLOCK_SELECTOR === $selector ? ':root :where(.%2$s %3$s)' : ':root :where(%1$s-%2$s %3$s)'; + $format = static::ROOT_BLOCK_SELECTOR === $selector ? ':root :where(.%2$s)%3$s' : ':root :where(%1$s-%2$s)%3$s'; $layout_selector = sprintf( $format, $selector,