File tree Expand file tree Collapse file tree
packages/block-editor/src/layouts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ import {
2323 * Internal dependencies
2424 */
2525import { appendSelectors , getBlockGapCSS } from './utils' ;
26- import { getGapCSSValue } from '../hooks/gap' ;
26+ import { getGapCSSValue , getGapBoxControlValueFromStyle } from '../hooks/gap' ;
27+ import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils' ;
2728import {
2829 BlockControls ,
2930 JustifyContentControl ,
@@ -147,15 +148,12 @@ export default {
147148 // falling back to '0.5em' for backwards compatibility.
148149 let fallbackGapValue = '0.5em' ;
149150 if ( globalBlockGapValue ) {
150- // Process the global gap value to handle preset values
151- const processedGlobalGap = getGapCSSValue (
152- globalBlockGapValue ,
153- '0.5em'
154- ) ;
155- // Use the column gap value (second value if two values exist)
156- const gapParts = processedGlobalGap . split ( ' ' ) ;
151+ const gapBox =
152+ getGapBoxControlValueFromStyle ( globalBlockGapValue ) ;
157153 fallbackGapValue =
158- gapParts . length > 1 ? gapParts [ 1 ] : gapParts [ 0 ] ;
154+ getSpacingPresetCssVar ( gapBox ?. left ) ||
155+ getSpacingPresetCssVar ( gapBox ?. top ) ||
156+ '0.5em' ;
159157 }
160158
161159 // If a block's block.json skips serialization for spacing or spacing.blockGap,
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ import { useState } from '@wordpress/element';
2121 * Internal dependencies
2222 */
2323import { appendSelectors , getBlockGapCSS } from './utils' ;
24- import { getGapCSSValue } from '../hooks/gap' ;
24+ import { getGapCSSValue , getGapBoxControlValueFromStyle } from '../hooks/gap' ;
25+ import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils' ;
2526import { shouldSkipSerialization } from '../hooks/utils' ;
2627import { LAYOUT_DEFINITIONS } from './definitions' ;
2728
@@ -143,10 +144,12 @@ export default {
143144 // If the gap value has both top and left (separated by space), use the left value for horizontal calculations.
144145 let fallbackGapValue = '1.2rem' ;
145146 if ( globalBlockGapValue ) {
146- const processedGap = getGapCSSValue ( globalBlockGapValue , '0.5em' ) ;
147- const gapParts = processedGap . split ( ' ' ) ;
147+ const gapBox =
148+ getGapBoxControlValueFromStyle ( globalBlockGapValue ) ;
148149 fallbackGapValue =
149- gapParts . length > 1 ? gapParts [ 1 ] : gapParts [ 0 ] ;
150+ getSpacingPresetCssVar ( gapBox ?. left ) ||
151+ getSpacingPresetCssVar ( gapBox ?. top ) ||
152+ '1.2rem' ;
150153 }
151154
152155 // If a block's block.json skips serialization for spacing or spacing.blockGap,
You can’t perform that action at this time.
0 commit comments