Make WordPress Core

Changeset 64322


Ignore:
Timestamp:
10/13/2026 05:49:42 AM (11 days ago)
Author:
isabel_brison
Message:

Editor: unset incompatible dimensions styles in viewport states.

Re-adds a missed line from a previous Gutenberg sync to enable unsetting height and min-height when aspect ratio is set for a viewport state, and vice versa.

Props isabel_brison, westonruter, marian1, abditsori.
Fixes #66275.

Location:
trunk
Files:
2 edited

Legend:

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

    r64117 r64322  
    365365 *
    366366 * @since 7.1.0
     367 * @since 7.2.0 Added fallback dimension styles.
    367368 *
    368369 * @param array       $css_rules   Style rules.
    … …  
    376377                return;
    377378        }
     379
     380        $style = wp_get_state_style_with_fallback_dimension_styles( $style );
    378381
    379382        $compiled     = wp_style_engine_get_styles(
  • trunk/tests/phpunit/tests/block-supports/states.php

    r64117 r64322  
    882882
    883883                $this->assertSame( $expected, $actual );
     884        }
     885
     886        /**
     887         * Tests that rendered state CSS includes fallback dimension declarations.
     888         *
     889         * @covers ::wp_render_block_states_support
     890         * @covers ::wp_add_block_state_style_rule
     891         *
     892         * @ticket 66275
     893         */
     894        public function test_responsive_height_generates_aspect_ratio_unset_in_stylesheet() {
     895                $this->ensure_block_registered( 'test/responsive-root-state' );
     896
     897                $block = array(
     898                        'blockName' => 'test/responsive-root-state',
     899                        'attrs'     => array(
     900                                'style' => array(
     901                                        '@mobile' => array(
     902                                                'dimensions' => array( 'minHeight' => '300px' ),
     903                                        ),
     904                                ),
     905                        ),
     906                );
     907
     908                $actual    = wp_render_block_states_support( '<div class="wp-block-test">Hello</div>', $block );
     909                $processor = new WP_HTML_Tag_Processor( $actual );
     910                $this->assertTrue( $processor->next_tag() );
     911
     912                $state_class = null;
     913                foreach ( $processor->class_list() as $class_name ) {
     914                        if ( str_starts_with( $class_name, 'wp-states-' ) ) {
     915                                $state_class = $class_name;
     916                                break;
     917                        }
     918                }
     919                $this->assertIsString( $state_class, 'Expected a wp-states-* class on the first tag.' );
     920
     921                $actual_stylesheet = wp_style_engine_get_stylesheet_from_context( 'block-supports', array( 'prettify' => false ) );
     922
     923                $this->assertStringContainsString(
     924                        "@media (width <= 480px){.{$state_class}{",
     925                        $actual_stylesheet
     926                );
     927                $this->assertStringContainsString( 'min-height:300px', $actual_stylesheet );
     928                $this->assertStringContainsString( 'aspect-ratio:unset', $actual_stylesheet );
    884929        }
    885930
Note: See TracChangeset for help on using the changeset viewer.