diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index 335d461b695f26..b3ee6d1f8b9d3e 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -1308,7 +1308,7 @@ public static function get_from_editor_settings( $settings ) { $theme_settings['settings']['spacing'] = array(); } $theme_settings['settings']['spacing']['units'] = ( true === $settings['enableCustomUnits'] ) ? - array( 'px', 'em', 'rem', 'vh', 'vw' ) : + array( 'px', 'em', 'rem', 'vh', 'vw', '%' ) : $settings['enableCustomUnits']; } diff --git a/lib/experimental-default-theme.json b/lib/experimental-default-theme.json index bf7ef9ef5147ba..0a24118a6a3e34 100644 --- a/lib/experimental-default-theme.json +++ b/lib/experimental-default-theme.json @@ -213,7 +213,7 @@ "spacing": { "customMargin": false, "customPadding": false, - "units": [ "px", "em", "rem", "vh", "vw" ] + "units": [ "px", "em", "rem", "vh", "vw", "%" ] }, "border": { "customColor": false, diff --git a/packages/block-editor/src/components/use-setting/index.js b/packages/block-editor/src/components/use-setting/index.js index d302ceb277425f..f82b7e38f0d2ec 100644 --- a/packages/block-editor/src/components/use-setting/index.js +++ b/packages/block-editor/src/components/use-setting/index.js @@ -41,7 +41,7 @@ const deprecatedFlags = { } if ( settings.enableCustomUnits === true ) { - return [ 'px', 'em', 'rem', 'vh', 'vw' ]; + return [ 'px', 'em', 'rem', 'vh', 'vw', '%' ]; } return settings.enableCustomUnits; diff --git a/phpunit/class-wp-theme-json-test.php b/phpunit/class-wp-theme-json-test.php index 6d44ca15362111..87dc387c4444f9 100644 --- a/phpunit/class-wp-theme-json-test.php +++ b/phpunit/class-wp-theme-json-test.php @@ -1476,7 +1476,7 @@ function test_get_from_editor_settings() { ), ), 'spacing' => array( - 'units' => array( 'px', 'em', 'rem', 'vh', 'vw' ), + 'units' => array( 'px', 'em', 'rem', 'vh', 'vw', '%' ), ), 'typography' => array( 'customFontSize' => false, @@ -1578,7 +1578,7 @@ function test_get_editor_settings_custom_units_can_be_enabled() { $input = gutenberg_get_default_block_editor_settings(); $expected = array( - 'units' => array( 'px', 'em', 'rem', 'vh', 'vw' ), + 'units' => array( 'px', 'em', 'rem', 'vh', 'vw', '%' ), 'customPadding' => false, );