From a476121c209bf0f67da64964f8fcacab36d50ac0 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Thu, 25 May 2023 20:54:23 +0900 Subject: [PATCH] SpacingSizesControl: Fix problem with the slider position being reset when saving global styles --- .../components/global-styles/dimensions-panel.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 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 d884f46bfda1cf..3a4a2b3230fa99 100644 --- a/packages/block-editor/src/components/global-styles/dimensions-panel.js +++ b/packages/block-editor/src/components/global-styles/dimensions-panel.js @@ -207,8 +207,19 @@ export default function DimensionsPanel( { // in global styles but not in block inspector. includeLayoutControls = false, } ) { - const decodeValue = ( rawValue ) => - getValueFromVariable( { settings }, '', rawValue ); + const decodeValue = ( rawValue ) => { + if ( typeof rawValue === 'object' ) { + return Object.keys( rawValue ).reduce( ( acc, key ) => { + acc[ key ] = getValueFromVariable( + { settings }, + '', + rawValue[ key ] + ); + return acc; + }, {} ); + } + return getValueFromVariable( { settings }, '', rawValue ); + }; const showSpacingPresetsControl = useHasSpacingPresets( settings ); const units = useCustomUnits( {