-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[$1000] Web - Workspace - An error is visible when go back from Connect manually #13024
Comments
Triggered auto assignment to @NicMendonca ( |
Proposal
Solution Add preventDefault when click back will do the trick. - onBackButtonPress={() => BankAccounts.setBankAccountSubStep(null)}
+ onBackButtonPress={(e) => { BankAccounts.setBankAccountSubStep(null); e.preventDefault(); }} We can also add onLongPress event too incase we don't want the input to loose focus when long click. Screen.Recording.2022-11-25.at.17.54.13.mov |
Current assignee @NicMendonca is eligible for the External assigner, not assigning anyone new. |
Job added to Upwork: https://www.upwork.com/jobs/~016000f297c530dd31 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia ( |
Triggered auto assignment to @flodnv ( |
This behaviour is present at every page that is using |
ProblemWe're not preventing default in the SolutionFollowing is a generic solution that works across all pages. diff --git a/src/components/HeaderWithCloseButton.js b/src/components/HeaderWithCloseButton.js
index 27ab5dbbe..3a2a94336 100755
--- a/src/components/HeaderWithCloseButton.js
+++ b/src/components/HeaderWithCloseButton.js
@@ -202,7 +202,10 @@ class HeaderWithCloseButton extends Component {
&& (
<Tooltip text={this.props.translate('common.close')}>
<Pressable
- onPress={this.props.onCloseButtonPress}
+ onPress={(e) => {
+ e.preventDefault();
+ this.props.onCloseButtonPress(e);
+ }}
style={[styles.touchableButtonImage, styles.mr0]}
accessibilityRole="button"
accessibilityLabel={this.props.translate('common.close')}
|
Updated ProposalProblemThe issue is that clicking on the FixWe need to not fire validation in the
Thus the following changes: diff --git a/src/components/Form.js b/src/components/Form.js
index 4734381bc..423a9ec81 100644
--- a/src/components/Form.js
+++ b/src/components/Form.js
@@ -217,7 +217,10 @@ class Form extends React.Component {
ref: node => this.inputRefs[inputID] = node,
value: this.state.inputValues[inputID],
errorText: this.state.errors[inputID] || fieldErrorMessage,
- onBlur: () => {
+ onBlur: (e) => {
+ if (e.relatedTarget && 'tabIndex' in e.relatedTarget && e.relatedTarget.tabIndex < 1) {
+ return e.preventDefault();
+ }
this.setTouchedInput(inputID);
this.validate(this.state.inputValues);
},
ResultScreen.Recording.2022-11-26.at.2.44.51.AM.mov |
ProposalWe encountered a similar issue on #12715 and fixed it by calling |
@Delgee |
@allroundexperts I think validating input on focus loss is correct behavior. And we should be able to validate input even if the focus is lost because of a click outside of |
@Delgee We are validating the input if the focus is lost because of click outside the Form. It's just for specific elements (like href), that when clicked, we don't want to validate. Also, TabIndex is just a single way to do it. As mentioned in proposal, we can use id / class as well to pinpoint this further. Also, If we change this on every page, I'm sure this will come up again when new pages get added. |
@allroundexperts Yes, we just don't want to validate in specific cases, not general cases. So we should fix this issue in those specific cases. |
ProposalProblemAs mentioned before SolutionWe can handle mouse event for the form and only validate when mouse is inside the form , this will prevent any validation when we click outside the diff --git a/src/components/Form.js b/src/components/Form.js
index 4734381bc9..6a47329fa9 100644
--- a/src/components/Form.js
+++ b/src/components/Form.js
@@ -75,6 +75,7 @@ class Form extends React.Component {
this.state = {
errors: {},
inputValues: {},
+ focused: false,
};
this.inputRefs = {};
@@ -83,6 +84,7 @@ class Form extends React.Component {
this.setTouchedInput = this.setTouchedInput.bind(this);
this.validate = this.validate.bind(this);
this.submit = this.submit.bind(this);
+ this.toggleFocus = this.toggleFocus.bind(this);
}
/**
@@ -128,6 +130,10 @@ class Form extends React.Component {
this.props.onSubmit(this.state.inputValues);
}
+ toggleFocus() {
+ this.setState(prev => ({focused: !prev.focused}));
+ }
+
/**
* @param {Object} values - An object containing the value of each inputID, e.g. {inputID1: value1, inputID2: value2}
* @returns {Object} - An object containing the errors for each inputID, e.g. {inputID1: error1, inputID2: error2}
@@ -218,6 +224,9 @@ class Form extends React.Component {
value: this.state.inputValues[inputID],
errorText: this.state.errors[inputID] || fieldErrorMessage,
onBlur: () => {
+ if (!this.state.focused) {
+ return;
+ }
this.setTouchedInput(inputID);
this.validate(this.state.inputValues);
},
@@ -249,6 +258,8 @@ class Form extends React.Component {
style={[styles.w100, styles.flex1]}
contentContainerStyle={styles.flexGrow1}
keyboardShouldPersistTaps="handled"
+ onMouseEnter={this.toggleFocus}
+ onMouseLeave={this.toggleFocus}
>
<View style={[this.props.style]}>
{this.childrenWrapperWithProps(this.props.children)} |
Thank you for the discussion everyone. For now let's hold on that discussion, see you there! |
Commented in the linked thread. I think we should close this issue. Taking it off hold in any case because the discussion there is wrapping up. |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Action Performed:
Expected Result:
There should NOT be any error
Actual Result:
An error is visible
Workaround:
Unknown
Platform:
Where is this issue occurring?
Version Number: 1.2.31.5
Reproducible in staging?: Yes
Reproducible in production?: Yes
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Bug5835453_Recording__3072.mp4
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: