From 16a4e87df1fbc8253740967d51f9e483eeb6de60 Mon Sep 17 00:00:00 2001
From: sobitneupane <073bct543.sobit@pcampus.edu.np>
Date: Mon, 11 Apr 2022 13:00:09 +0545
Subject: [PATCH 1/2] Keep focus on textinput field after pressing enter when
button is disabled
---
src/pages/iou/steps/IOUAmountPage.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/pages/iou/steps/IOUAmountPage.js b/src/pages/iou/steps/IOUAmountPage.js
index 5ebccbbcb6ee..2fe38c178c78 100755
--- a/src/pages/iou/steps/IOUAmountPage.js
+++ b/src/pages/iou/steps/IOUAmountPage.js
@@ -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.onBlur = this.onBlur.bind(this);
this.state = {
amount: props.selectedAmount,
@@ -93,6 +94,16 @@ class IOUAmountPage extends React.Component {
this.focusTextInput();
}
+ /**
+ * Return focus on textinput if no amount is entered.
+ */
+ onBlur() {
+ if (this.state.amount !== '') {
+ return;
+ }
+ this.textInput.focus();
+ }
+
/**
* Focus text input
*/
@@ -236,6 +247,7 @@ class IOUAmountPage extends React.Component {
value={formattedAmount}
placeholder={this.props.numberFormat(0)}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
+ onBlur={this.onBlur}
/>
From f88b00529881642b661414f64833744cdc474c2f Mon Sep 17 00:00:00 2001
From: sobitneupane <073bct543.sobit@pcampus.edu.np>
Date: Tue, 19 Apr 2022 17:44:21 +0545
Subject: [PATCH 2/2] Change name and docstring of onBlur function
---
src/pages/iou/steps/IOUAmountPage.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/pages/iou/steps/IOUAmountPage.js b/src/pages/iou/steps/IOUAmountPage.js
index 2fe38c178c78..fd415c7b6913 100755
--- a/src/pages/iou/steps/IOUAmountPage.js
+++ b/src/pages/iou/steps/IOUAmountPage.js
@@ -75,7 +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.onBlur = this.onBlur.bind(this);
+ this.focusEmptyInput = this.focusEmptyInput.bind(this);
this.state = {
amount: props.selectedAmount,
@@ -95,9 +95,9 @@ class IOUAmountPage extends React.Component {
}
/**
- * Return focus on textinput if no amount is entered.
+ * Keep TextInput focused if no amount is entered.
*/
- onBlur() {
+ focusEmptyInput() {
if (this.state.amount !== '') {
return;
}
@@ -247,7 +247,7 @@ class IOUAmountPage extends React.Component {
value={formattedAmount}
placeholder={this.props.numberFormat(0)}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
- onBlur={this.onBlur}
+ onBlur={this.focusEmptyInput}
/>