Skip to content

Commit 7293127

Browse files
committed
Fix -0.00 showing up.
Closes #249
1 parent 57cd267 commit 7293127

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

apps/studio/src/components/NumericInput.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@ const NumericInput = ({
4646
const num = clampValue(isPositiveInteger ? parseInt(string) : parseFloat(string))
4747
return isNaN(num) ? defaultValue : num
4848
}, [isPositiveInteger, defaultValue, clampValue])
49-
const numToString = useCallback((value: number | null | undefined) => value?.toFixed(isPositiveInteger ? 0 : 2) ?? "", [isPositiveInteger])
49+
const numToString = useCallback((value: number | null | undefined) => {
50+
if (value === null || value === undefined) {
51+
return ""
52+
}
53+
if (value === 0) {
54+
value = 0; //This is to prevent -0 from showing up
55+
}
56+
return value.toFixed(isPositiveInteger ? 0 : 2)
57+
}, [isPositiveInteger])
5058

5159
const [typedValue, setTypedValue] = useState(numToString(value))
5260
const [isFocused, setIsFocused] = useState(false)

0 commit comments

Comments
 (0)