2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Updated currency field to prevent floating point issues (#19221)

refs ADM-54
This commit is contained in:
Jono M 2023-12-04 15:27:52 +00:00 committed by GitHub
parent ede2d9c1b7
commit b450db557b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,7 +26,7 @@ const CurrencyField: React.FC<CurrencyFieldProps> = ({
// The saved value is strictly a number with 2 decimal places
const forceCurrencyValue = (input: string) => {
return Math.floor(parseFloat(input.match(/[\d]+\.?[\d]{0,2}/)?.[0] || '0') * 100);
return Math.round(parseFloat(input.match(/[\d]+\.?[\d]{0,2}/)?.[0] || '0') * 100);
};
return <TextField