Skip to content

Commit

Permalink
Merge pull request #8591 from sobitneupane/sn_bug-iouamountpage-retur…
Browse files Browse the repository at this point in the history
…n-key

Keep focus on textinput field after pressing enter when button is disabled
  • Loading branch information
Beamanator authored Apr 27, 2022
2 parents 26c6e3b + f88b005 commit f3b5685
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/pages/iou/steps/IOUAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class IOUAmountPage extends React.Component {
this.updateAmount = this.updateAmount.bind(this);
this.stripCommaFromAmount = this.stripCommaFromAmount.bind(this);
this.focusTextInput = this.focusTextInput.bind(this);
this.focusEmptyInput = this.focusEmptyInput.bind(this);

this.state = {
amount: props.selectedAmount,
Expand All @@ -93,6 +94,16 @@ class IOUAmountPage extends React.Component {
this.focusTextInput();
}

/**
* Keep TextInput focused if no amount is entered.
*/
focusEmptyInput() {
if (this.state.amount !== '') {
return;
}
this.textInput.focus();
}

/**
* Focus text input
*/
Expand Down Expand Up @@ -236,6 +247,7 @@ class IOUAmountPage extends React.Component {
value={formattedAmount}
placeholder={this.props.numberFormat(0)}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
onBlur={this.focusEmptyInput}
/>
</View>
<View style={[styles.w100, styles.justifyContentEnd]}>
Expand Down

0 comments on commit f3b5685

Please sign in to comment.