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.

Backports the PHP changes in https://github.com/WordPress/gutenberg/pull/63436.

Fixes #61656.
Props andrewserong, mukesh27, aaronrobertshaw.

Built from https://develop.svn.wordpress.org/trunk@58750


git-svn-id: http://core.svn.wordpress.org/trunk@58152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
noisysocks 2024-07-18 06:50:10 +00:00
parent a4e3fdfa3a
commit ab39abeed7
2 changed files with 11 additions and 3 deletions

View File

@ -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)" ),

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-58749';
$wp_version = '6.7-alpha-58750';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.