From 1e9373fbb499435f8263c516c1bb5522ec7360da Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Wed, 8 Apr 2026 14:52:08 +1000 Subject: [PATCH 1/3] Block Supports: Add min width support to dimension supports --- src/wp-includes/block-supports/dimensions.php | 2 +- src/wp-includes/class-wp-theme-json.php | 4 ++ .../style-engine/class-wp-style-engine.php | 9 +++ .../wpApplyDimensionsSupport.php | 71 +++++++++++++++++++ .../tests/style-engine/styleEngine.php | 18 ++++- tests/phpunit/tests/theme/wpThemeJson.php | 6 ++ 6 files changed, 108 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/block-supports/dimensions.php b/src/wp-includes/block-supports/dimensions.php index 381f7bc3fb8be..beb6e374604c6 100644 --- a/src/wp-includes/block-supports/dimensions.php +++ b/src/wp-includes/block-supports/dimensions.php @@ -64,7 +64,7 @@ function wp_apply_dimensions_support( $block_type, $block_attributes ) { } $dimensions_block_styles = array(); - $supported_features = array( 'minHeight', 'height', 'width' ); + $supported_features = array( 'minHeight', 'minWidth', 'height', 'width' ); foreach ( $supported_features as $feature ) { $has_support = block_has_support( $block_type, array( 'dimensions', $feature ), false ); diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 61b076dd872cc..0569dd6fad789 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -294,6 +294,7 @@ class WP_Theme_JSON { 'margin-bottom' => array( 'spacing', 'margin', 'bottom' ), 'margin-left' => array( 'spacing', 'margin', 'left' ), 'min-height' => array( 'dimensions', 'minHeight' ), + 'min-width' => array( 'dimensions', 'minWidth' ), 'outline-color' => array( 'outline', 'color' ), 'outline-offset' => array( 'outline', 'offset' ), 'outline-style' => array( 'outline', 'style' ), @@ -458,6 +459,7 @@ class WP_Theme_JSON { 'dimensionSizes' => null, 'height' => null, 'minHeight' => null, + 'minWidth' => null, 'width' => null, ), 'layout' => array( @@ -589,6 +591,7 @@ class WP_Theme_JSON { 'aspectRatio' => null, 'height' => null, 'minHeight' => null, + 'minWidth' => null, 'width' => null, ), 'filter' => array( @@ -1045,6 +1048,7 @@ public static function get_element_class_name( $element ) { array( 'dimensions', 'aspectRatio' ), array( 'dimensions', 'height' ), array( 'dimensions', 'minHeight' ), + array( 'dimensions', 'minWidth' ), array( 'dimensions', 'width' ), array( 'position', 'sticky' ), array( 'spacing', 'blockGap' ), diff --git a/src/wp-includes/style-engine/class-wp-style-engine.php b/src/wp-includes/style-engine/class-wp-style-engine.php index 97b9981e598f7..21dea5ea65978 100644 --- a/src/wp-includes/style-engine/class-wp-style-engine.php +++ b/src/wp-includes/style-engine/class-wp-style-engine.php @@ -242,6 +242,15 @@ final class WP_Style_Engine { 'dimension' => '--wp--preset--dimension--$slug', ), ), + 'minWidth' => array( + 'property_keys' => array( + 'default' => 'min-width', + ), + 'path' => array( 'dimensions', 'minWidth' ), + 'css_vars' => array( + 'dimension' => '--wp--preset--dimension--$slug', + ), + ), 'objectFit' => array( 'property_keys' => array( 'default' => 'object-fit', diff --git a/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php b/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php index 897bcd0dd04f5..6fd58f4e56dec 100644 --- a/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php +++ b/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php @@ -242,4 +242,75 @@ public function data_height_block_support() { ), ); } + + /** + * Tests that minimum width block support works as expected. + * + * @ticket 65037 + * + * @covers ::wp_apply_dimensions_support + * + * @dataProvider data_minimum_width_block_support + * + * @param string $block_name The test block name to register. + * @param mixed $dimensions The dimensions block support settings. + * @param mixed $expected The expected results. + */ + public function test_minimum_width_block_support( $block_name, $dimensions, $expected ) { + $this->test_block_name = $block_name; + register_block_type( + $this->test_block_name, + array( + 'api_version' => 2, + 'attributes' => array( + 'style' => array( + 'type' => 'object', + ), + ), + 'supports' => array( + 'dimensions' => $dimensions, + ), + ) + ); + $registry = WP_Block_Type_Registry::get_instance(); + $block_type = $registry->get_registered( $this->test_block_name ); + $block_attrs = array( + 'style' => array( + 'dimensions' => array( + 'minWidth' => '200px', + ), + ), + ); + + $actual = wp_apply_dimensions_support( $block_type, $block_attrs ); + + $this->assertSame( $expected, $actual ); + } + + /** + * Data provider. + * + * @return array + */ + public function data_minimum_width_block_support() { + return array( + 'style is applied' => array( + 'block_name' => 'test/min-width-style-is-applied', + 'dimensions' => array( + 'minWidth' => true, + ), + 'expected' => array( + 'style' => 'min-width:200px;', + ), + ), + 'style output is skipped when individual feature serialization is skipped' => array( + 'block_name' => 'test/min-width-with-individual-skipped-serialization-block-supports', + 'dimensions' => array( + 'minWidth' => true, + '__experimentalSkipSerialization' => array( 'minWidth' ), + ), + 'expected' => array(), + ), + ); + } } diff --git a/tests/phpunit/tests/style-engine/styleEngine.php b/tests/phpunit/tests/style-engine/styleEngine.php index 0327ca66bbc6a..fe858e07cb6a7 100644 --- a/tests/phpunit/tests/style-engine/styleEngine.php +++ b/tests/phpunit/tests/style-engine/styleEngine.php @@ -24,6 +24,7 @@ class Tests_wpStyleEngine extends WP_UnitTestCase { * @ticket 62189 * @ticket 63799 * @ticket 64974 + * @ticket 65037 * * @covers ::wp_style_engine_get_styles * @@ -207,7 +208,7 @@ public function data_wp_style_engine_get_styles() { ), ), - 'inline_valid_dimensions_style' => array( + 'inline_valid_dimensions_min_height_style' => array( 'block_styles' => array( 'dimensions' => array( 'minHeight' => '50vh', @@ -222,6 +223,21 @@ public function data_wp_style_engine_get_styles() { ), ), + 'inline_valid_dimensions_min_width_style' => array( + 'block_styles' => array( + 'dimensions' => array( + 'minWidth' => '25vw', + ), + ), + 'options' => null, + 'expected_output' => array( + 'css' => 'min-width:25vw;', + 'declarations' => array( + 'min-width' => '25vw', + ), + ), + ), + 'inline_valid_aspect_ratio_style' => array( 'block_styles' => array( 'dimensions' => array( diff --git a/tests/phpunit/tests/theme/wpThemeJson.php b/tests/phpunit/tests/theme/wpThemeJson.php index d9a51a98af260..6d9f52db184dc 100644 --- a/tests/phpunit/tests/theme/wpThemeJson.php +++ b/tests/phpunit/tests/theme/wpThemeJson.php @@ -47,6 +47,7 @@ public static function set_up_before_class() { /** * @ticket 52991 * @ticket 54336 + * @ticket 65037 */ public function test_get_settings() { $theme_json = new WP_Theme_JSON( @@ -231,6 +232,9 @@ public function test_get_settings_presets_are_keyed_by_origin() { $this->assertEqualSetsWithIndex( $expected_no_origin, $actual_no_origin ); } + /** + * @ticket 65037 + */ public function test_get_settings_appearance_true_opts_in() { $theme_json = new WP_Theme_JSON( array( @@ -283,6 +287,7 @@ public function test_get_settings_appearance_true_opts_in() { 'aspectRatio' => true, 'height' => true, 'minHeight' => true, + 'minWidth' => true, 'width' => true, ), 'position' => array( @@ -325,6 +330,7 @@ public function test_get_settings_appearance_true_opts_in() { 'aspectRatio' => true, 'height' => true, 'minHeight' => true, + 'minWidth' => true, 'width' => true, ), 'position' => array( From 2f55952a298e98b108bc80b985bc147734b51749 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Wed, 8 Apr 2026 16:59:12 +1000 Subject: [PATCH 2/3] Add since annotations for new minWidth support in theme.json class --- src/wp-includes/class-wp-theme-json.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 0569dd6fad789..78aaa5ff5beee 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -248,6 +248,7 @@ class WP_Theme_JSON { * @since 6.7.0 Added `background-attachment` property. * @since 7.0.0 Added `dimensions.width` and `dimensions.height`. * Added `text-indent` property. + * @since 7.1.0 Added `min-width` property. * @var array */ const PROPERTIES_METADATA = array( @@ -417,6 +418,7 @@ class WP_Theme_JSON { * Added support for `typography.textIndent`. * @since 7.1.0 Added `viewport` property. * Added support for `background.gradient`. + * Added support for `dimensions.minWidth`. * @var array */ const VALID_SETTINGS = array( @@ -561,6 +563,7 @@ class WP_Theme_JSON { * @since 6.6.0 Added `background` sub properties to top-level only. * @since 7.0.0 Added support for `dimensions.width` and `dimensions.height`. * @since 7.1.0 Added `background.gradient`. + * Added support for `dimensions.minWidth`. * @var array */ const VALID_STYLES = array( @@ -1031,6 +1034,7 @@ public static function get_element_class_name( $element ) { * @since 6.5.0 Added `background.backgroundSize` and `dimensions.aspectRatio`. * @since 7.0.0 Added `dimensions.width` and `dimensions.height`. * @since 7.1.0 Added `background.gradient`. + * Added `dimensions.minWidth`. * @var array */ const APPEARANCE_TOOLS_OPT_INS = array( From cea4ee62276ae5400b7371f6076fce8e7a1dad33 Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 14 Jul 2026 17:11:02 +1000 Subject: [PATCH 3/3] Update class-wp-theme-json.php Fixed annotation --- src/wp-includes/class-wp-theme-json.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index fe7c10ee92f07..f9c2ddec0fc51 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -417,12 +417,7 @@ class WP_Theme_JSON { * Added support for `dimensions.width` and `dimensions.height`. * Added support for `typography.textIndent`. * @since 7.1.0 Added `viewport` property. -<<<<<<< add/min-width-support - * Added support for `background.gradient`. - * Added support for `dimensions.minWidth`. -======= - * Added support for `background.gradient` and `blockVisibility.allowEditing`. ->>>>>>> trunk + * Added support for `background.gradient`, `dimensions.minWidth` and `blockVisibility.allowEditing`. * @var array */ const VALID_SETTINGS = array(