Max length for InputNumber (equal to allowed digits) (#4034)

* Max length for InputNumber (equal to allowed digits)

* Description on length check
This commit is contained in:
Jaco Greeff 2020-11-16 16:35:03 +01:00 committed by GitHub
parent e7fbe3bc38
commit 685971fa09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -243,7 +243,10 @@ function InputNumber ({ autoFocus, bitLength = DEFAULT_BITLENGTH, children, clas
[_onChangeWithSi, value]
);
const maxValueLength = getGlobalMaxValue(bitLength).toString().length - 1;
// Same as the number of digits, which means it can still overflow, i.e.
// for u8 we allow 3, which could be 999 (however 2 digits will limit to only 99,
// so this is more-or-less the lesser of evils without a max-value check)
const maxValueLength = getGlobalMaxValue(bitLength).toString().length;
return (
<Input