Skip to content
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

Highlight all errors together in BankAccount step #5041

Merged
merged 7 commits into from
Sep 3, 2021

Conversation

aldo-expensify
Copy link
Contributor

@aldo-expensify aldo-expensify commented Sep 3, 2021

cc @marcaaron

Brought some of the functionality implemented in this dead PR

Details

Changes:

  • Added missing inline error for field Account Number
  • "Save & continue" button is only disabled if there is some field empty or the checkbox is unchecked
  • Support highlighting multiple errors at the same time
  • Clear error of field being edited

These changes apply only to BankAccount step in VBA flow.

Fixed Issues

$ #4785

Tests AND QA Steps

  1. Start with a non-public domain account that has not yet set up a workspace or bank account
  2. Create a new workspace by tapping on the green FAB button
  3. Navigate to /bank-account by selecting the workspace and tapping the "Get Started" button
  4. Tap button to add account manually: Connect manually
  5. Expected result: the "Save & continue" button should be disabled.
  6. Enter an invalid Routing number, i.e.: 1 (front-end validation)
  7. Expected result: the "Save & continue" button should remain disabled.
  8. Enter an invalid Account number, i.e.: 1 (front-end validation)
  9. Click "Save & continue"
  10. Expected result: You should get the error modal with the generic message: Please double check any highlighted fields and try again. and see both fields with inline highlighted errors
    Screen Shot 2021-09-02 at 5 06 30 PM
  11. Focus on any of the inputs, type something more
  12. Expected result: the inline error and highlight should disappear only for that input.
    Screen Shot 2021-09-02 at 5 07 15 PM
  13. Enter 33333332234 as Routing number and 111 as the Account number
  14. Click "Save & continue"
  15. Expected result: We should see the loading transition (data is sent to back-end), and then we should see the form again with an inline error for Routing number and the error modal with the generic message.
Screen.Recording.2021-09-02.at.5.50.11.PM.mov

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Mobile Web

Desktop

iOS

Android

Support highlighting multiple errors
Only disable submit button if there are empty fields
Clear error of field being edited
@aldo-expensify aldo-expensify self-assigned this Sep 3, 2021
@aldo-expensify aldo-expensify marked this pull request as ready for review September 3, 2021 00:29
@aldo-expensify aldo-expensify requested a review from a team as a code owner September 3, 2021 00:29
@MelvinBot MelvinBot requested review from AndrewGable and removed request for a team September 3, 2021 00:29
@aldo-expensify aldo-expensify changed the title Highlight all errors together in BankAccount step [WIP] Highlight all errors together in BankAccount step Sep 3, 2021
@aldo-expensify
Copy link
Contributor Author

Sorry, making this [WIP] again because I didn't consider the case of the error coming from the server.

@aldo-expensify aldo-expensify changed the title [WIP] Highlight all errors together in BankAccount step Highlight all errors together in BankAccount step Sep 3, 2021
@aldo-expensify
Copy link
Contributor Author

Update: When the backend returns a validation error for the 'Routing number' we highlight correctly the field again.

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I just had mostly style things to add + a question about how we should handle the Onyx workaround.

src/libs/actions/BankAccounts.js Show resolved Hide resolved
@@ -822,7 +832,7 @@ function setupWithdrawalAccount(data) {
}

function hideBankAccountErrors() {
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {error: '', existingOwnersList: ''});
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {error: '', existingOwnersList: '', errors: {}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably you'll get conflicts if my other PR is merged, but I noticed that existingOwnersList isn't actually used anywhere but existingOwners is - so let's make sure this bug doesn't get reintroduced here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change existingOwnersList for existingOwners now? or we handle it once there is conflict?

I didn't know you could do a search like that in Github, cool feature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it doesn't matter yet, but just pointing out the code you have here does nothing so probably we should update it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we actually clearing the errors if we do errors: {}? This will need to be errors: null I think?

Copy link
Contributor Author

@aldo-expensify aldo-expensify Sep 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we actually clearing the errors if we do errors: {}? This will need to be errors: null I think?

You are right, I was clearing this the wrong way. 🤦 How does it work in the case of arrays? do they get merged (concatenated) or replaced?

The answer: the old array gets replaced by the new array (no merging/concatenating)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm just going to set it to null and the will clear the key. When we get the errors we get them using lodashGet(this.props, ['reimbursementAccount', 'errors'], {}). I feel like setting this to null and then {} is uglier and doesn't make things much better.

src/pages/ReimbursementAccount/BankAccountStep.js Outdated Show resolved Hide resolved
src/pages/ReimbursementAccount/BankAccountStep.js Outdated Show resolved Hide resolved
@aldo-expensify
Copy link
Contributor Author

Update: pushed some changes addressing comments

@aldo-expensify
Copy link
Contributor Author

Update:

  • hideBankAccountErrors sets the errors key to null
  • Added comment for setBankAccountFormValidationErrors

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marcaaron
Copy link
Contributor

Gonna merge this so we can keep the ball rolling. I'm going to spend some time looking into the Onyx improvement.

@marcaaron marcaaron merged commit 4bb007b into main Sep 3, 2021
@marcaaron marcaaron deleted the aldo_errors-bank-account-vba branch September 3, 2021 20:56
@OSBotify
Copy link
Contributor

OSBotify commented Sep 3, 2021

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Sep 4, 2021

🚀 Deployed to staging by @marcaaron in version: 1.0.93-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Sep 8, 2021

🚀 Deployed to production by @yuwenmemon in version: 1.0.94-1 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants