Make WordPress Core


Ignore:
Timestamp:
09/26/2022 02:56:41 PM (2 years ago)
Author:
hellofromTonya
Message:

Editor: Fix spacing property generation in flow layout type.

Fixes a bug of invalid CSS value when applying block spacing to a block as reported in Gutenberg issue 44435.

Adds logic to convert preset values (i.e. $gap_value) into valid CSS custom properties for the flow ('default') layout type. See the original fix in Gutenberg PR 3324.

Also adds a test dataset that fails before the bugfix and passes after the bugix.

Follow-up to [54274].

Props ndiego, isabel_brison, ramonopoly, andrewserong, hellofromTonya.
See #56467.

File:
1 edited

Legend:

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

    r54275 r54311  
    5757            }
    5858            if ( null !== $gap_value && ! $should_skip_gap_serialization ) {
     59                // Get spacing CSS variable from preset value if provided.
     60                if ( is_string( $gap_value ) && str_contains( $gap_value, 'var:preset|spacing|' ) ) {
     61                    $index_to_splice = strrpos( $gap_value, '|' ) + 1;
     62                    $slug            = _wp_to_kebab_case( substr( $gap_value, $index_to_splice ) );
     63                    $gap_value       = "var(--wp--preset--spacing--$slug)";
     64                }
     65
    5966                array_push(
    6067                    $layout_styles,
Note: See TracChangeset for help on using the changeset viewer.