From f0d0c0eacb483efe55bd1650ccc414a93ea41c80 Mon Sep 17 00:00:00 2001 From: himanshupathak95 Date: Thu, 23 Jan 2025 12:52:13 +0530 Subject: [PATCH] Block Editor: Prevent negative width values in Spacer block when used inside a row block --- .../src/components/child-layout-control/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/block-editor/src/components/child-layout-control/index.js b/packages/block-editor/src/components/child-layout-control/index.js index 20791d9751bcd..699949637693d 100644 --- a/packages/block-editor/src/components/child-layout-control/index.js +++ b/packages/block-editor/src/components/child-layout-control/index.js @@ -48,6 +48,7 @@ function helpText( selfStretch, parentLayout ) { * * @param {boolean} props.isShownByDefault * @param {string} props.panelId + * @param {number} [props.minUnitValue=0] Minimum allowed value for the unit control * @return {Element} child layout edit element. */ export default function ChildLayoutControl( { @@ -56,6 +57,7 @@ export default function ChildLayoutControl( { parentLayout, isShownByDefault, panelId, + minUnitValue = 0, } ) { const { type: parentType, @@ -71,6 +73,7 @@ export default function ChildLayoutControl( { parentLayout={ parentLayout } isShownByDefault={ isShownByDefault } panelId={ panelId } + minUnitValue={ minUnitValue } /> ); } else if ( parentLayoutType === 'grid' ) { @@ -94,6 +97,7 @@ function FlexControls( { parentLayout, isShownByDefault, panelId, + minUnitValue, } ) { const { selfStretch, flexSize } = childLayout; const { orientation = 'horizontal' } = parentLayout ?? {}; @@ -188,6 +192,7 @@ function FlexControls( { } ); } } value={ flexSize } + min={ minUnitValue } label={ flexResetLabel } hideLabelFromVision />