Fix empty state for currency inputs in product editor (#38697)
This commit is contained in:
parent
bfd720c28f
commit
ce770bbfd2
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: fix
|
||||
|
||||
Fix empty state for currency inputs in product editor
|
|
@ -81,7 +81,7 @@ export const useCurrencyInputProps = ( {
|
|||
}
|
||||
},
|
||||
onChange( newValue: string ) {
|
||||
const sanitizeValue = sanitizePrice( newValue || '0' );
|
||||
const sanitizeValue = sanitizePrice( newValue );
|
||||
if ( onChange ) {
|
||||
onChange( sanitizeValue );
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue