From d08a55a2db7e067e3e095be1f0f79a31a29dfd69 Mon Sep 17 00:00:00 2001 From: Mayank-Tripathi32 Date: Sat, 21 Dec 2024 01:15:13 +0530 Subject: [PATCH] feat: fixed child block unit controls issue with unit reset --- .../src/components/child-layout-control/index.js | 6 ++++++ 1 file changed, 6 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 20791d9751bcd4..e300ff84b83ebb 100644 --- a/packages/block-editor/src/components/child-layout-control/index.js +++ b/packages/block-editor/src/components/child-layout-control/index.js @@ -10,6 +10,7 @@ import { __experimentalVStack as VStack, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalUseCustomUnits as useCustomUnits, + __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue, Flex, FlexItem, } from '@wordpress/components'; @@ -182,6 +183,11 @@ function FlexControls( { size="__unstable-large" units={ units } onChange={ ( value ) => { + if ( value === '' ) { + const [ , currentUnit ] = + parseQuantityAndUnitFromRawValue( flexSize ); + value = `0${ currentUnit || 'px' }`; + } onChange( { selfStretch, flexSize: value,