From 7bc9cd8c943972b2800e70fc6eaaf9c01ff5c488 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 10 Oct 2018 16:43:55 -0700 Subject: Fix issue where we throw if non-numeric characters are used in input --- packages/instant/src/components/amount_input.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'packages/instant/src') diff --git a/packages/instant/src/components/amount_input.tsx b/packages/instant/src/components/amount_input.tsx index 29d1bf161..12cb9a48c 100644 --- a/packages/instant/src/components/amount_input.tsx +++ b/packages/instant/src/components/amount_input.tsx @@ -29,11 +29,16 @@ export class AmountInput extends React.Component { ); } - private readonly _handleChange = (event: React.ChangeEvent): void => { + private _handleChange = (event: React.ChangeEvent): void => { const value = event.target.value; let bigNumberValue; if (!_.isEmpty(value)) { - bigNumberValue = new BigNumber(event.target.value); + try { + bigNumberValue = new BigNumber(event.target.value); + } catch { + // We don't want to allow values that can't be a BigNumber, so don't even call onChange. + return; + } } if (!_.isUndefined(this.props.onChange)) { this.props.onChange(bigNumberValue); -- cgit