Jelajahi Sumber

Fixed NaN issue when parsing

Hugo Häggmark 7 tahun lalu
induk
melakukan
f16a2c0f48

+ 3 - 1
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.tsx

@@ -95,10 +95,12 @@ export class ThresholdsEditor extends PureComponent<Props, State> {
     }
     }
 
 
     const { thresholds } = this.state;
     const { thresholds } = this.state;
+    const parsedValue = parseInt(event.target.value, 10);
+    const value = isNaN(parsedValue) ? null : parsedValue;
 
 
     const newThresholds = thresholds.map(t => {
     const newThresholds = thresholds.map(t => {
       if (t === threshold) {
       if (t === threshold) {
-        t = { ...t, value: parseInt(event.target.value, 10) };
+        t = { ...t, value: value as number };
       }
       }
 
 
       return t;
       return t;