Skip to content

Commit

Permalink
Spacer: Show simple control if less than two preset spacing sizes (#6…
Browse files Browse the repository at this point in the history
…8818)


Co-authored-by: stokesman <[email protected]>
Co-authored-by: carolinan <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2025
1 parent ed64574 commit 682e4c7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/block-library/src/spacer/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ function DimensionInput( { label, onChange, isResizing, value = '' } ) {
defaultValues: { px: 100, em: 10, rem: 10, vw: 10, vh: 25 },
} );

const handleOnChange = ( unprocessedValue ) => {
onChange( unprocessedValue.all );
};

// Force the unit to update to `px` when the Spacer is being resized.
const [ parsedQuantity, parsedUnit ] =
parseQuantityAndUnitFromRawValue( value );
Expand All @@ -57,23 +53,24 @@ function DimensionInput( { label, onChange, isResizing, value = '' } ) {

return (
<>
{ ( ! spacingSizes || spacingSizes?.length === 0 ) && (
{ spacingSizes?.length < 2 ? (
<UnitControl
id={ inputId }
isResetValueOnUnitChange
min={ MIN_SPACER_SIZE }
onChange={ handleOnChange }
onChange={ onChange }
value={ computedValue }
units={ units }
label={ label }
__next40pxDefaultSize
/>
) }
{ spacingSizes?.length > 0 && (
) : (
<View className="tools-panel-item-spacing">
<SpacingSizesControl
values={ { all: computedValue } }
onChange={ handleOnChange }
onChange={ ( { all } ) => {
onChange( all );
} }
label={ label }
sides={ [ 'all' ] }
units={ units }
Expand Down

0 comments on commit 682e4c7

Please sign in to comment.