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
This commit is contained in:
hellofromTonya 2024-07-18 17:04:15 +00:00
parent e6d8ac1656
commit 2ce6913586
2 changed files with 11 additions and 3 deletions

View File

@ -323,6 +323,10 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
*/
if ( isset( $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)" ),
@ -330,6 +334,10 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
}
if ( isset( $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)" ),

View File

@ -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.