diff --git a/src/components/ui/form-numeric-input.tsx b/src/components/ui/form-numeric-input.tsx index 43371d3..ecf7250 100644 --- a/src/components/ui/form-numeric-input.tsx +++ b/src/components/ui/form-numeric-input.tsx @@ -132,6 +132,18 @@ const FormNumericInput = React.forwardRef( setShowWarning(hasWarning) } + // Ensure value is consistently formatted to the required decimal places + React.useEffect(() => { + const strVal = String(value) + if (strVal === '') return + const num = Number(strVal) + if (isNaN(num)) return + const formatted = num.toFixed(decimalPlaces) + if (strVal !== formatted) { + onChange(formatted) + } + }, [value, decimalPlaces, onChange]) + const getAlignmentClass = () => { switch (align) { case 'left': return 'text-left'