Browse Source

fix(dashboard): Do not emit NaN values from number input

Michael Bromley 3 months ago
parent
commit
3e3ab3e013
1 changed files with 6 additions and 1 deletions
  1. 6 1
      packages/dashboard/src/lib/components/data-input/number-input.tsx

+ 6 - 1
packages/dashboard/src/lib/components/data-input/number-input.tsx

@@ -22,7 +22,12 @@ export function NumberInput({ fieldDef, onChange, ...fieldProps }: Readonly<Dash
     const shouldUseAffixedInput = prefix || suffix;
     const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
         if (readOnly) return;
-        onChange(e.target.valueAsNumber);
+        const numValue = e.target.valueAsNumber;
+        if (Number.isNaN(numValue)) {
+            onChange(e.target.value);
+        } else {
+            onChange(e.target.valueAsNumber);
+        }
     };
     if (shouldUseAffixedInput) {
         return (