diff --git a/source/components/CurrencyInput/CurrencyInput.js b/source/components/CurrencyInput/CurrencyInput.js index f9fd66eb3..36b216a0f 100644 --- a/source/components/CurrencyInput/CurrencyInput.js +++ b/source/components/CurrencyInput/CurrencyInput.js @@ -1,7 +1,7 @@ import classnames from 'classnames' import { omit } from 'ramda' import React, { Component } from 'react' -import { debounce, isIE } from '../../utils' +import { debounce } from '../../utils' import './CurrencyInput.css' let isCurrencyPrefixed = language => @@ -21,39 +21,13 @@ class CurrencyInput extends Component { : this.props.onChange input = React.createRef() - getSnapshotBeforeUpdate = () => { - if (!this.input.current) { - return - } - return this.input.current.selectionStart - } - componentDidMount() { - this.adaptInputSize() - } - adaptInputSize = () => { - // Because ch mesurement in IE is not consistent with other browsers, we have to apply a multiplier - // https://stackoverflow.com/questions/17825638/css3-ch-unit-inconsistent-between-ie9-and-other-browsers - const widthMultiplier = isIE() ? 1.4 : 1 - - if (this.input.current && isCurrencyPrefixed(this.props.language)) - this.input.current.style.width = - widthMultiplier * (this.input.current.value.length + 0.2) + 'ch' - } - componentDidUpdate = (_, __, cursorPosition) => { - if (!this.input.current) { - return - } - this.input.current.selectionStart = cursorPosition - this.input.current.selectionEnd = cursorPosition - this.adaptInputSize() - } handleChange = event => { let value = event.target.value value = value .replace(/,/g, '.') .replace(/[^\d.]/g, '') .replace(/\.(.*)\.(.*)/g, '$1.$2') - this.setState({ value }, this.adaptInputSize) + this.setState({ value }) if (value.endsWith('.')) { return