From c5e6c1a6bf271b28837b79c939efe74a80b6fe1e Mon Sep 17 00:00:00 2001 From: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:03:19 +1100 Subject: [PATCH] Ensure block support is checked properly --- .../components/global-styles/dimensions-panel.js | 3 --- .../src/components/global-styles/hooks.js | 15 +++++++++------ packages/blocks/src/api/constants.js | 5 +++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/dimensions-panel.js b/packages/block-editor/src/components/global-styles/dimensions-panel.js index e8d0eaa4dd3837..a367abddff628a 100644 --- a/packages/block-editor/src/components/global-styles/dimensions-panel.js +++ b/packages/block-editor/src/components/global-styles/dimensions-panel.js @@ -373,9 +373,6 @@ export default function DimensionsPanel( { setImmutably( value, [ 'dimensions', 'aspectRatio' ], newValue ) ); }; - // const resetAspectRatioValue = () => { - // setAspectRatioValue( undefined ); - // }; const hasAspectRatioValue = () => !! value?.dimensions?.aspectRatio; // Child Layout diff --git a/packages/block-editor/src/components/global-styles/hooks.js b/packages/block-editor/src/components/global-styles/hooks.js index 356ff4dce57a90..7d3351b6391b40 100644 --- a/packages/block-editor/src/components/global-styles/hooks.js +++ b/packages/block-editor/src/components/global-styles/hooks.js @@ -46,6 +46,7 @@ const VALID_SETTINGS = [ 'color.palette', 'color.text', 'custom', + 'dimensions.aspectRatio', 'dimensions.minHeight', 'layout.contentSize', 'layout.definitions', @@ -339,12 +340,14 @@ export function useSettingsForBlockElement( } } ); - if ( ! supportedStyles.includes( 'minHeight' ) ) { - updatedSettings.dimensions = { - ...updatedSettings.dimensions, - minHeight: false, - }; - } + [ 'aspectRatio', 'minHeight' ].forEach( ( key ) => { + if ( ! supportedStyles.includes( key ) ) { + updatedSettings.dimensions = { + ...updatedSettings.dimensions, + [ key ]: false, + }; + } + } ); [ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => { if ( diff --git a/packages/blocks/src/api/constants.js b/packages/blocks/src/api/constants.js index 2afdee93278ce7..8c3f5b5d0e0869 100644 --- a/packages/blocks/src/api/constants.js +++ b/packages/blocks/src/api/constants.js @@ -20,6 +20,11 @@ export const __EXPERIMENTAL_STYLE_PROPERTY = { value: [ 'color', 'link' ], support: [ 'color', 'link' ], }, + aspectRatio: { + value: [ 'dimensions', 'aspectRatio' ], + support: [ 'dimensions', 'aspectRatio' ], + useEngine: true, + }, background: { value: [ 'color', 'gradient' ], support: [ 'color', 'gradients' ],