fix: Fixes #340 prevent spaces in InputNumber (#341)

* currently user cannot enter "0 ", but this prevents user from entering a space after any digit, i.e. "3 4" or "3  " or "3   3  3  "
This commit is contained in:
Luke Schoen 2018-09-30 20:59:55 +10:00 committed by Jaco Greeff
parent 3626705ada
commit 759070488a
2 changed files with 7 additions and 4 deletions

View File

@ -87,10 +87,16 @@ describe('InputNumber', () => {
it('throws an error if input value for comparison is not a string', () => {
const invalidInputValueType = 340282366920938463463374607431768211456;
expect(() => { wrapper.instance().isValidNumber(invalidInputValueType, '0', DEFAULT_BITLENGTH); }).toThrow();
expect(() => { wrapper.instance().isValidNumber(invalidInputValueType, DEFAULT_BITLENGTH); }).toThrow();
});
});
it('should not be valid when input contains spaces', () => {
const invalidInputValueType = '3 4';
expect(wrapper.instance().isValidNumber(invalidInputValueType, DEFAULT_BITLENGTH)).toBe(false);
});
it('should not be valid when user enters positive value greater than or equal to the 128 bit max for latest chain', () => {
expect(wrapper.instance().isValidNumber(max128BN.toString(10), DEFAULT_BITLENGTH)).toBe(false);
});

View File

@ -126,9 +126,6 @@ class InputNumber extends React.PureComponent<Props, State> {
}));
}
// remove spaces even though not possible as user restricted from entering spacebar key in onKeyDown
input = input.toLowerCase().split(' ').join('');
if (this.isNonInteger(input)) {
return false;
}