diff --git a/src/components/BigNumberPad.js b/src/components/BigNumberPad.js index e28eefbd122d..7e9a79ba0c7f 100644 --- a/src/components/BigNumberPad.js +++ b/src/components/BigNumberPad.js @@ -28,7 +28,7 @@ const padNumbers = [ ['.', '0', '<'], ]; -class BigNumberPad extends React.Component { +class BigNumberPad extends React.PureComponent { constructor(props) { super(props); diff --git a/src/pages/iou/steps/IOUAmountPage.js b/src/pages/iou/steps/IOUAmountPage.js index ed0009814209..cd1d0ccac967 100755 --- a/src/pages/iou/steps/IOUAmountPage.js +++ b/src/pages/iou/steps/IOUAmountPage.js @@ -52,14 +52,15 @@ class IOUAmountPage extends React.Component { super(props); this.updateAmountNumberPad = this.updateAmountNumberPad.bind(this); + this.updateLongPressHandlerState = this.updateLongPressHandlerState.bind(this); this.updateAmount = this.updateAmount.bind(this); this.stripCommaFromAmount = this.stripCommaFromAmount.bind(this); this.focusTextInput = this.focusTextInput.bind(this); this.navigateToCurrencySelectionPage = this.navigateToCurrencySelectionPage.bind(this); - this.shouldUpdateSelection = true; this.state = { amount: props.selectedAmount, + shouldUpdateSelection: true, selection: { start: props.selectedAmount.length, end: props.selectedAmount.length, @@ -196,6 +197,15 @@ class IOUAmountPage extends React.Component { }); } + /** + * Update long press value, to remove items pressing on < + * + * @param {Boolean} value - Changed text from user input + */ + updateLongPressHandlerState(value) { + this.setState({shouldUpdateSelection: value}); + } + /** * Update amount on amount change * Validate new amount with decimal number regex up to 6 digits and 2 decimal digit @@ -263,7 +273,7 @@ class IOUAmountPage extends React.Component { selectedCurrencyCode={this.props.iou.selectedCurrencyCode || CONST.CURRENCY.USD} selection={this.state.selection} onSelectionChange={(e) => { - if (!this.shouldUpdateSelection) { + if (!this.state.shouldUpdateSelection) { return; } this.setState({selection: e.nativeEvent.selection}); @@ -275,7 +285,7 @@ class IOUAmountPage extends React.Component { ? ( this.shouldUpdateSelection = !state} + longPressHandlerStateChanged={this.updateLongPressHandlerState} /> ) : }