format numbers

Reviewed By: lblasa

Differential Revision: D50653525

fbshipit-source-id: 265a2821acef572ca6d9576be647ee1d07f3850e
This commit is contained in:
Luke De Feo
2023-10-26 05:24:30 -07:00
committed by Facebook GitHub Bot
parent 8af6ca7f02
commit 20a1b9d255

View File

@@ -326,6 +326,11 @@ function StyledInput({
mutable: boolean; mutable: boolean;
rightAddon?: string; rightAddon?: string;
}) { }) {
let formatted: any = value;
if (typeof value === 'number') {
//cap the number of decimal places to 5 but dont add trailing zeros
formatted = Number.parseFloat(value.toFixed(5));
}
return ( return (
<Input <Input
size="small" size="small"
@@ -347,7 +352,7 @@ function StyledInput({
)} )}
bordered bordered
readOnly={!mutable} readOnly={!mutable}
value={value} value={formatted}
suffix={rightAddon} suffix={rightAddon}
/> />
); );