diff --git a/packages/ui/src/components/Forms/Inputs/FloatInput.tsx b/packages/ui/src/components/Forms/Inputs/FloatInput.tsx index 804900b141..ecce7ddf68 100644 --- a/packages/ui/src/components/Forms/Inputs/FloatInput.tsx +++ b/packages/ui/src/components/Forms/Inputs/FloatInput.tsx @@ -35,8 +35,8 @@ export const FloatInput = memo(forwardRef(({ ? (value) .replaceAll(',', '.') .replace(/[^\d.-]/g, '') - .replace(/^(\d+\.\d+|\d+).*/, '$1') - .replace(/^0*(?=\d)/, '') + .replace(/^(-?\d+\.\d+|\d+).*/, '$1') + .replace(/^(-?)0+/, (match, p1) => p1 === '-' ? '-0' : '') : '' if (number.current !== value) { diff --git a/packages/ui/src/components/Forms/Inputs/NumberInput.tsx b/packages/ui/src/components/Forms/Inputs/NumberInput.tsx index 51e557fbe8..b0c516aabc 100644 --- a/packages/ui/src/components/Forms/Inputs/NumberInput.tsx +++ b/packages/ui/src/components/Forms/Inputs/NumberInput.tsx @@ -32,11 +32,13 @@ export const NumberInput = memo(forwardRef(( onChange: useCallback((value?: string | null) => { value = typeof value === 'string' && value.trim() !== '' ? (value) - .replace(/[^\d]/g, '') - .replace(/^0*(?=\d)/, '') + .trim() + .replace(/[^0-9-]|(? p1 === '-' ? '-0' : '') : null - onChange?.(value ? parseInt(value) : null) + const int = value ? parseInt(value, 10) : null + onChange?.(int === null || isNaN(int) ? null : int) }, [onChange]), value: value?.toString(10), }, forwardedRed)