diff --git a/packages/js/product-editor/changelog/fix-38623 b/packages/js/product-editor/changelog/fix-38623 new file mode 100644 index 00000000000..7f2a88a4405 --- /dev/null +++ b/packages/js/product-editor/changelog/fix-38623 @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Fix empty state for currency inputs in product editor diff --git a/packages/js/product-editor/src/hooks/use-currency-input-props.ts b/packages/js/product-editor/src/hooks/use-currency-input-props.ts index f92e141bae7..b4aabcd0d09 100644 --- a/packages/js/product-editor/src/hooks/use-currency-input-props.ts +++ b/packages/js/product-editor/src/hooks/use-currency-input-props.ts @@ -81,7 +81,7 @@ export const useCurrencyInputProps = ( { } }, onChange( newValue: string ) { - const sanitizeValue = sanitizePrice( newValue || '0' ); + const sanitizeValue = sanitizePrice( newValue ); if ( onChange ) { onChange( sanitizeValue ); } diff --git a/packages/js/product-editor/src/hooks/use-product-helper.ts b/packages/js/product-editor/src/hooks/use-product-helper.ts index b55178bd511..fc8da5d5a02 100644 --- a/packages/js/product-editor/src/hooks/use-product-helper.ts +++ b/packages/js/product-editor/src/hooks/use-product-helper.ts @@ -312,6 +312,10 @@ export function useProductHelper() { */ const sanitizePrice = useCallback( ( price: string ) => { + if ( ! price.length ) { + return ''; + } + const { getCurrencyConfig } = context; const { decimalSeparator } = getCurrencyConfig(); // Build regex to strip out everything except digits, decimal point and minus sign.