From 2ce691358681038b74fc632a65d9049961373c52 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Thu, 18 Jul 2024 17:04:15 +0000 Subject: [PATCH] Block Themes: Fix invalid css for nested fullwidth layouts with zero padding applied In the Layout block support, handle 0 values for padding as 0px in calc() rules. This resolves a bug for nested fullwidth layouts when zero padding is applied. Due to how calc() works, without supplying the unit, the rule will not work, resulting in a horizontal scrollbar. Ref: PHP changes from https://github.com/WordPress/gutenberg/pull/63436. Reviewed by hellofromTonya. Merges [58750] to the 6.6 branch. Fixes #61656. Props andrewserong, mukesh27, aaronrobertshaw. Built from https://develop.svn.wordpress.org/branches/6.6@58761 git-svn-id: http://core.svn.wordpress.org/branches/6.6@58163 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/block-supports/layout.php | 12 ++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wp-includes/block-supports/layout.php b/wp-includes/block-supports/layout.php index e1894cdb72..ccfb2005aa 100644 --- a/wp-includes/block-supports/layout.php +++ b/wp-includes/block-supports/layout.php @@ -322,14 +322,22 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false * They're added separately because padding might only be set on one side. */ if ( isset( $block_spacing_values['declarations']['padding-right'] ) ) { - $padding_right = $block_spacing_values['declarations']['padding-right']; + $padding_right = $block_spacing_values['declarations']['padding-right']; + // Add unit if 0. + if ( '0' === $padding_right ) { + $padding_right = '0px'; + } $layout_styles[] = array( 'selector' => "$selector > .alignfull", 'declarations' => array( 'margin-right' => "calc($padding_right * -1)" ), ); } if ( isset( $block_spacing_values['declarations']['padding-left'] ) ) { - $padding_left = $block_spacing_values['declarations']['padding-left']; + $padding_left = $block_spacing_values['declarations']['padding-left']; + // Add unit if 0. + if ( '0' === $padding_left ) { + $padding_left = '0px'; + } $layout_styles[] = array( 'selector' => "$selector > .alignfull", 'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ), diff --git a/wp-includes/version.php b/wp-includes/version.php index e406b6c057..215963486b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6.1-alpha-58760'; +$wp_version = '6.6.1-alpha-58761'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.