Make WordPress Core

Changeset 58243


Ignore:
Timestamp:
05/30/2024 04:08:56 AM (6 months ago)
Author:
isabel_brison
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-supports/layout.php

    r58241 r58243  
    225225 * @since 6.3.0 Added grid layout type.
    226226 * @since 6.6.0 Removed duplicated selector from layout styles.
     227 *              Enabled negative margins for alignfull children of blocks with custom padding.
    227228 * @access private
    228229 *
     
    308309                )
    309310            );
    310 
    311             if ( isset( $block_spacing ) ) {
    312                 $block_spacing_values = wp_style_engine_get_styles(
    313                     array(
    314                         'spacing' => $block_spacing,
    315                     )
     311        }
     312
     313        if ( isset( $block_spacing ) ) {
     314            $block_spacing_values = wp_style_engine_get_styles(
     315                array(
     316                    'spacing' => $block_spacing,
     317                )
     318            );
     319
     320            /*
     321             * Handle negative margins for alignfull children of blocks with custom padding set.
     322             * They're added separately because padding might only be set on one side.
     323             */
     324            if ( isset( $block_spacing_values['declarations']['padding-right'] ) ) {
     325                $padding_right   = $block_spacing_values['declarations']['padding-right'];
     326                $layout_styles[] = array(
     327                    'selector'     => "$selector > .alignfull",
     328                    'declarations' => array( 'margin-right' => "calc($padding_right * -1)" ),
    316329                );
    317 
    318                 /*
    319                  * Handle negative margins for alignfull children of blocks with custom padding set.
    320                  * They're added separately because padding might only be set on one side.
    321                  */
    322                 if ( isset( $block_spacing_values['declarations']['padding-right'] ) ) {
    323                     $padding_right   = $block_spacing_values['declarations']['padding-right'];
    324                     $layout_styles[] = array(
    325                         'selector'     => "$selector > .alignfull",
    326                         'declarations' => array( 'margin-right' => "calc($padding_right * -1)" ),
    327                     );
    328                 }
    329                 if ( isset( $block_spacing_values['declarations']['padding-left'] ) ) {
    330                     $padding_left    = $block_spacing_values['declarations']['padding-left'];
    331                     $layout_styles[] = array(
    332                         'selector'     => "$selector > .alignfull",
    333                         'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ),
    334                     );
    335                 }
     330            }
     331            if ( isset( $block_spacing_values['declarations']['padding-left'] ) ) {
     332                $padding_left    = $block_spacing_values['declarations']['padding-left'];
     333                $layout_styles[] = array(
     334                    'selector'     => "$selector > .alignfull",
     335                    'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ),
     336                );
    336337            }
    337338        }
Note: See TracChangeset for help on using the changeset viewer.