-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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] Routing Number shows an error before typing anything #24044
Comments
Triggered auto assignment to @flaviadefaria ( |
Bug0 Triage Checklist (Main S/O)
|
ProposalPlease re-state the problem that we are trying to solve in this issue.The issue is that the Routing Number field in the form shows a validation error prematurely when the keyboard is closed without entering any input. What is the root cause of that problem?The root cause is the inconsistency between the initial values of Lines 98 to 104 in 577152d
Lines 268 to 271 in 577152d
What changes do you think we should make in order to solve the problem?One solution is to set
This change ensures that This logic can also be done out of this callback function when the values are initially being set |
Job added to Upwork: https://www.upwork.com/jobs/~01c0ac78d2c9b90a4f |
Current assignee @flaviadefaria is eligible for the External assigner, not assigning anyone new. |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia ( |
Proposal, I am submitting my proposal to resolve the "Routing Number" error display issue in the FormAlertWrapper component. The current problem displays an error message prematurely, even before any user input. To address this, I will make the following changes: Conditional Error Rendering: I will update the FormAlertWrapper to show error messages only when there are validation issues or when users attempt to submit incomplete forms. Enhanced Offline Handling: The component will handle offline scenarios gracefully, displaying appropriate messages to inform users about their connection status. Accessibility & Localization: I will ensure that the error messages are accessible and support multi-language localization. My goal is to deliver a polished solution that improves the user experience by providing accurate error feedback and seamless form interactions. I am excited to collaborate on this project and welcome any specific preferences or additional requirements you may have. Thank you for considering my proposal. I am eager to contribute to your project's success. Best regards, |
📣 @hanzalahsamana! 📣
|
Expensify account email: hanzalahsamana789@gmail.com |
Proposal About Bank Account Manual Step - Form Validation EnhancementProblem Statement:In the Bank Account Manual Step component, there is an issue with form validation where error messages persist even after the user closes the input field without entering any data. This creates a confusing user experience as the errors should disappear when the user starts typing. Root Cause:The issue arises from how the error state is managed in the component. The current implementation does not handle the scenario when the user closes the input field without entering any data, resulting in the error message remaining visible. Proposed Solution:Please check my fixed solution in the below video now no errors are shown initially only errors are shown on continue button pressed: Expensify.Bug.Solution.mp4To fix the form validation issue and ensure a smooth user experience, the following changes are recommended:
Updated Code:Relative Path of file: import React from 'react';
import {Image} from 'react-native';
import lodashGet from 'lodash/get';
import HeaderWithBackButton from '../../components/HeaderWithBackButton';
import CONST from '../../CONST';
import * as BankAccounts from '../../libs/actions/BankAccounts';
import Text from '../../components/Text';
import TextInput from '../../components/TextInput';
import styles from '../../styles/styles';
import CheckboxWithLabel from '../../components/CheckboxWithLabel';
import TextLink from '../../components/TextLink';
import withLocalize from '../../components/withLocalize';
import * as ValidationUtils from '../../libs/ValidationUtils';
import ONYXKEYS from '../../ONYXKEYS';
import exampleCheckImage from './exampleCheckImage';
import Form from '../../components/Form';
import shouldDelayFocus from '../../libs/shouldDelayFocus';
import ScreenWrapper from '../../components/ScreenWrapper';
import StepPropTypes from './StepPropTypes';
const propTypes = {
...StepPropTypes,
};
class BankAccountManualStep extends React.Component {
constructor(props) {
super(props);
this.state = {
errors: {},
isFormSubmitted: false, // New state property to track form submission
};
this.submit = this.submit.bind(this);
this.validate = this.validate.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
}
handleInputChange(inputID, value) {
// Clear the error for the specific input when the user starts typing
this.setState((prevState) => ({
errors: {
...prevState.errors,
[inputID]: undefined,
},
}));
}
validate(values) {
// Only set the errors if the form is submitted
if (this.state.isFormSubmitted) {
const errorFields = {};
const routingNumber = values.routingNumber && values.routingNumber.trim();
if (
!values.accountNumber ||
(!CONST.BANK_ACCOUNT.REGEX.US_ACCOUNT_NUMBER.test(values.accountNumber.trim()) && !CONST.BANK_ACCOUNT.REGEX.MASKED_US_ACCOUNT_NUMBER.test(values.accountNumber.trim()))
) {
errorFields.accountNumber = this.props.translate('bankAccount.error.accountNumber');
} else if (values.accountNumber === routingNumber) {
errorFields.accountNumber = this.props.translate('bankAccount.error.routingAndAccountNumberCannotBeSame');
}
if (!routingNumber || !CONST.BANK_ACCOUNT.REGEX.SWIFT_BIC.test(routingNumber) || !ValidationUtils.isValidRoutingNumber(routingNumber)) {
errorFields.routingNumber = this.props.translate('bankAccount.error.routingNumber');
}
if (!values.acceptTerms) {
errorFields.acceptTerms = this.props.translate('common.error.acceptTerms');
}
this.setState({errors: errorFields});
return errorFields;
}
return {};
}
submit(values) {
// Set isFormSubmitted to true when the form is submitted
this.setState({isFormSubmitted: true});
// If values of routing number and account number are empty give error
if (!values.routingNumber || !values.accountNumber) {
// alert('Please enter routing number and account number');
const errorFields = {};
const routingNumber = values.routingNumber && values.routingNumber.trim();
if (
!values.accountNumber ||
(!CONST.BANK_ACCOUNT.REGEX.US_ACCOUNT_NUMBER.test(values.accountNumber.trim()) && !CONST.BANK_ACCOUNT.REGEX.MASKED_US_ACCOUNT_NUMBER.test(values.accountNumber.trim()))
) {
errorFields.accountNumber = 'bankAccount.error.accountNumber';
} else if (values.accountNumber === routingNumber) {
errorFields.accountNumber = this.props.translate('bankAccount.error.routingAndAccountNumberCannotBeSame');
}
if (!routingNumber || !CONST.BANK_ACCOUNT.REGEX.SWIFT_BIC.test(routingNumber) || !ValidationUtils.isValidRoutingNumber(routingNumber)) {
errorFields.routingNumber = 'bankAccount.error.routingNumber';
}
if (!values.acceptTerms) {
errorFields.acceptTerms = 'common.error.acceptTerms';
}
this.setState({errors: errorFields});
return errorFields;
} else {
BankAccounts.connectBankAccountManually(
lodashGet(this.props.reimbursementAccount, 'achData.bankAccountID') || 0,
values.accountNumber,
values.routingNumber,
lodashGet(this.props, ['reimbursementAccountDraft', 'plaidMask']),
);
}
}
render() {
const shouldDisableInputs = Boolean(lodashGet(this.props.reimbursementAccount, 'achData.bankAccountID'));
return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<HeaderWithBackButton
title={this.props.translate('workspace.common.connectBankAccount')}
stepCounter={{step: 1, total: 5}}
shouldShowGetAssistanceButton
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_BANK_ACCOUNT}
onBackButtonPress={this.props.onBackButtonPress}
/>
<Form
formID={ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM}
onSubmit={this.submit}
validate={this.validate}
// Remove onFocus/onBlur when we have a better solution for
submitButtonText={this.props.translate('common.continue')}
style={[styles.mh5, styles.flexGrow1]}
>
<Text style={[styles.mb5]}>{this.props.translate('bankAccount.checkHelpLine')}</Text>
<Image
resizeMode="contain"
style={[styles.exampleCheckImage, styles.mb5]}
source={exampleCheckImage(this.props.preferredLocale)}
/>
<TextInput
autoFocus
shouldDelayFocus={shouldDelayFocus}
inputID="routingNumber"
label={this.props.translate('bankAccount.routingNumber')}
defaultValue={this.props.getDefaultStateForField('routingNumber', '')}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
disabled={shouldDisableInputs}
shouldSaveDraft
shouldUseDefaultValue={shouldDisableInputs}
error={this.state.errors.routingNumber} // Pass the error message to the TextInput component
onChangeText={(value) => this.handleInputChange('routingNumber', value)}
/>
<TextInput
inputID="accountNumber"
containerStyles={[styles.mt4]}
label={this.props.translate('bankAccount.accountNumber')}
defaultValue={this.props.getDefaultStateForField('accountNumber', '')}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
disabled={shouldDisableInputs}
shouldSaveDraft
shouldUseDefaultValue={shouldDisableInputs}
error={this.state.errors.accountNumber} // Pass the error message to the TextInput component
onChangeText={(value) => this.handleInputChange('accountNumber', value)}
/>
<CheckboxWithLabel
style={styles.mt4}
inputID="acceptTerms"
LabelComponent={() => (
<Text>
{this.props.translate('common.iAcceptThe')}
<TextLink href={CONST.TERMS_URL}>{this.props.translate('common.expensifyTermsOfService')}</TextLink>
</Text>
)}
defaultValue={this.props.getDefaultStateForField('acceptTerms', false)}
shouldSaveDraft
error={this.state.errors.acceptTerms} // Pass the error message to the CheckboxWithLabel component
/>
</Form>
</ScreenWrapper>
);
}
}
BankAccountManualStep.propTypes = propTypes;
export default withLocalize(BankAccountManualStep); Please review these changes in which I have ensured that error messages are displayed correctly during form submission and cleared appropriately when the user interacts with the form. It will improve the overall user experience and streamline the validation process in the Bank Account Manual Step component. Looking forward to fixing it for production as well! |
📣 @mudassar69! 📣
|
Contributor details |
Regression from #23306 |
expected behaviour here should be that upon touching account no. field and blurring it, error on account no. should also be shown, like it happens on routing field @hungvu193 does your proposal solve #21838 and keep the touched errors too? If yes, then i think we should revert this PR and proceed with your proposal |
@thesahindia what do you think about @chiragxarora's comment above? |
As the person who authored #23306, I agree with @chiragxarora. I don't think we can fix this regression while keeping the solution we implemented in that PR. |
@flaviadefaria, since the regression period isn't over we should remove the |
I think we can put this on HOLD for now until we have decided the next step here, we can remove the external and help wanted label. |
Ok, I removed the 2 labels, put the issue on hold, and switched the priority to weekly. We'll wait for the next steps from you @techievivek. |
We have reverted the original fix #21838 (comment) that caused this regression, so we can close this now. |
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:
1- Click on your avatar
2- click on Worspaces option
3- select any workspace
4- Click on bank account option
5- click on Connect manually
6- Close the keyboard without typing anything
Expected Result:
Routing Number shouldn't show any error before typing ( Account Number works perfectly)
Actual Result:
Routing Number shows an error before typing anything
Workaround:
Can the user still use Expensify without this being fixed? Have you informed them of the workaround?
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.3.49-0
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Screen_Recording_20230730-163338.mp4
Recording.1430.mp4
Expensify/Expensify Issue URL:
Issue reported by: @mejed-alkoutaini
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690724240140599
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: