aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/currency-input.js
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-01-30 10:22:52 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-01-30 10:22:52 +0800
commitecc39c5a7abd8c8794d5565c1bc7d213d3514d61 (patch)
tree746f0a2bada5d8cd6636789d3c498c1ef13901fb /ui/app/components/currency-input.js
parentd905b86ba775aad888d1dfd22257958fd9415909 (diff)
parentb05d21b1ba308bdb5b758d53dd79593a7a2bf26e (diff)
downloadtangerine-wallet-browser-ecc39c5a7abd8c8794d5565c1bc7d213d3514d61.tar
tangerine-wallet-browser-ecc39c5a7abd8c8794d5565c1bc7d213d3514d61.tar.gz
tangerine-wallet-browser-ecc39c5a7abd8c8794d5565c1bc7d213d3514d61.tar.bz2
tangerine-wallet-browser-ecc39c5a7abd8c8794d5565c1bc7d213d3514d61.tar.lz
tangerine-wallet-browser-ecc39c5a7abd8c8794d5565c1bc7d213d3514d61.tar.xz
tangerine-wallet-browser-ecc39c5a7abd8c8794d5565c1bc7d213d3514d61.tar.zst
tangerine-wallet-browser-ecc39c5a7abd8c8794d5565c1bc7d213d3514d61.zip
Merge branch 'uat' of https://github.com/MetaMask/metamask-extension into cb-254
Diffstat (limited to 'ui/app/components/currency-input.js')
-rw-r--r--ui/app/components/currency-input.js14
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,
})
}