diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-01-16 06:37:59 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2018-01-16 10:28:21 +0800 |
commit | baebf64afd594316a4e160ff1d046ea68bfc5c70 (patch) | |
tree | c4d1a6da5d1ff6a80e5fdc6e2e20bd625a613f42 /ui/app/components/currency-input.js | |
parent | 644adeccf6b5365ef2c8c9a5ba69b90fdaa1f2ec (diff) | |
download | tangerine-wallet-browser-baebf64afd594316a4e160ff1d046ea68bfc5c70.tar tangerine-wallet-browser-baebf64afd594316a4e160ff1d046ea68bfc5c70.tar.gz tangerine-wallet-browser-baebf64afd594316a4e160ff1d046ea68bfc5c70.tar.bz2 tangerine-wallet-browser-baebf64afd594316a4e160ff1d046ea68bfc5c70.tar.lz tangerine-wallet-browser-baebf64afd594316a4e160ff1d046ea68bfc5c70.tar.xz tangerine-wallet-browser-baebf64afd594316a4e160ff1d046ea68bfc5c70.tar.zst tangerine-wallet-browser-baebf64afd594316a4e160ff1d046ea68bfc5c70.zip |
Fix send screen value input
Diffstat (limited to 'ui/app/components/currency-input.js')
-rw-r--r-- | ui/app/components/currency-input.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/ui/app/components/currency-input.js b/ui/app/components/currency-input.js index 66880091f..6f7862e51 100644 --- a/ui/app/components/currency-input.js +++ b/ui/app/components/currency-input.js @@ -50,10 +50,18 @@ function sanitizeValue (value) { CurrencyInput.prototype.handleChange = function (newValue) { const { onInputChange } = this.props + const { value } = this.state - this.setState({ value: sanitizeValue(newValue) }) + let parsedValue = newValue + const newValueLastIndex = newValue.length - 1 - onInputChange(sanitizeValue(newValue)) + if (value === '0' && newValue[newValueLastIndex] === '0') { + parsedValue = parsedValue.slice(0, newValueLastIndex) + } + + const sanitizedValue = sanitizeValue(parsedValue) + this.setState({ value: sanitizedValue }) + onInputChange(sanitizedValue) } // If state.value === props.value plus a decimal point, or at least one @@ -90,6 +98,6 @@ CurrencyInput.prototype.render = function () { size: valueToRender.length * inputSizeMultiplier, readOnly, onChange: e => this.handleChange(e.target.value), - ref: inputRef, + ref: inputRef, }) } |