Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/BigNumberPad.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const padNumbers = [
['.', '0', '<'],
];

class BigNumberPad extends React.Component {
class BigNumberPad extends React.PureComponent {
constructor(props) {
super(props);

Expand Down
16 changes: 13 additions & 3 deletions src/pages/iou/steps/IOUAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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});
Expand All @@ -275,7 +285,7 @@ class IOUAmountPage extends React.Component {
? (
<BigNumberPad
numberPressed={this.updateAmountNumberPad}
longPressHandlerStateChanged={state => this.shouldUpdateSelection = !state}
longPressHandlerStateChanged={this.updateLongPressHandlerState}
/>
) : <View />}

Expand Down