Editor: Negative margins for alignfull children of blocks with custom padding.

Fixes a condition that was preventing align full blocks to extend full width when their parent block has custom padding.

Props richtabor, isabel_brison, ramonopoly.
Fixes #61313.

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


git-svn-id: http://core.svn.wordpress.org/trunk@57706 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
isabel_brison 2024-05-30 04:10:09 +00:00
parent 1b218aaa39
commit f7515f439f
2 changed files with 26 additions and 25 deletions

View File

@ -224,6 +224,7 @@ function wp_register_layout_support( $block_type ) {
* @since 6.1.0 Added `$block_spacing` param, use style engine to enqueue styles. * @since 6.1.0 Added `$block_spacing` param, use style engine to enqueue styles.
* @since 6.3.0 Added grid layout type. * @since 6.3.0 Added grid layout type.
* @since 6.6.0 Removed duplicated selector from layout styles. * @since 6.6.0 Removed duplicated selector from layout styles.
* Enabled negative margins for alignfull children of blocks with custom padding.
* @access private * @access private
* *
* @param string $selector CSS selector. * @param string $selector CSS selector.
@ -307,32 +308,32 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
'declarations' => array( 'max-width' => 'none' ), 'declarations' => array( 'max-width' => 'none' ),
) )
); );
}
if ( isset( $block_spacing ) ) { if ( isset( $block_spacing ) ) {
$block_spacing_values = wp_style_engine_get_styles( $block_spacing_values = wp_style_engine_get_styles(
array( array(
'spacing' => $block_spacing, 'spacing' => $block_spacing,
) )
);
/*
* Handle negative margins for alignfull children of blocks with custom padding set.
* 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'];
$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'];
$layout_styles[] = array(
'selector' => "$selector > .alignfull",
'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ),
); );
/*
* Handle negative margins for alignfull children of blocks with custom padding set.
* 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'];
$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'];
$layout_styles[] = array(
'selector' => "$selector > .alignfull",
'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ),
);
}
} }
} }

View File

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