From f258067247bc1a6675c5bccaa6ab94652d8e56f7 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Thu, 27 Jul 2023 15:25:04 +1000 Subject: [PATCH 1/2] Check if spacing tool is defined before displaying controls. --- packages/block-editor/src/components/global-styles/hooks.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/global-styles/hooks.js b/packages/block-editor/src/components/global-styles/hooks.js index 9347afe54298e1..465d7dbc4a504b 100644 --- a/packages/block-editor/src/components/global-styles/hooks.js +++ b/packages/block-editor/src/components/global-styles/hooks.js @@ -326,7 +326,11 @@ export function useSettingsForBlockElement( const sides = Array.isArray( supports?.spacing?.[ key ] ) ? supports?.spacing?.[ key ] : supports?.spacing?.[ key ]?.sides; - if ( sides?.length ) { + // Check if spacing type actually exists before adding sides. + if ( + sides?.length && + typeof updatedSettings.spacing?.[ key ] !== 'undefined' + ) { updatedSettings.spacing = { ...updatedSettings.spacing, [ key ]: { From ca0a972ba527760c2075e54dbe028e54f3c64718 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Thu, 27 Jul 2023 16:15:34 +1000 Subject: [PATCH 2/2] Don't show sides if spacing type false --- .../block-editor/src/components/global-styles/hooks.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/hooks.js b/packages/block-editor/src/components/global-styles/hooks.js index 465d7dbc4a504b..abd7ebc61b7c77 100644 --- a/packages/block-editor/src/components/global-styles/hooks.js +++ b/packages/block-editor/src/components/global-styles/hooks.js @@ -326,11 +326,8 @@ export function useSettingsForBlockElement( const sides = Array.isArray( supports?.spacing?.[ key ] ) ? supports?.spacing?.[ key ] : supports?.spacing?.[ key ]?.sides; - // Check if spacing type actually exists before adding sides. - if ( - sides?.length && - typeof updatedSettings.spacing?.[ key ] !== 'undefined' - ) { + // Check if spacing type is supported before adding sides. + if ( sides?.length && updatedSettings.spacing?.[ key ] ) { updatedSettings.spacing = { ...updatedSettings.spacing, [ key ]: {