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 in VBA flow - Company step #5073

Merged
merged 15 commits into from
Sep 14, 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

Investigate: can functions like clearErrorAndSetValue be reused somehow? We will need to repeat this and other functions in every step.

Details

Changes:

  • Added missing errors for fields in Company Step (i.e. City)
  • Show all highlighted errors together in Company Step
  • The "Save & continue" button is disabled if the checkbox next to "I confirm that this company...." has not been checked or if there is any field left empty. Enabling the input in all cases will be handled when we address this GH issue

Fixed Issues

$ #4785

We are working in this issue step by step. This PR updates the error handling specifically for the company information step in the VBA flow.

Tests AND QA Steps

  1. Get to the step where we fill the "Company Information", two options:
    1. In a browser, navigate to /bank-account/company
    2. or do the following 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: Log in into your bank
      5. Enter data following step (3) Add Bank Account in this SO
        Screen Shot 2021-09-09 at 2 42 10 PM
  2. Fill all fields, and check the checkbox next to "I confirm that this company is not on the...". Make sure there is invalid data in Zip code, Company website, Tax ID number and Industry classification code. Invalid data could be for example 1.
  3. Once all fields have been filled, click "Save & continue"
  4. Expected result: You should get the error modal with the generic message: Please double check any highlighted fields and try again. and see all fields with inline highlighted errors at the same time: Screen Shot 2021-09-13 at 5 03 35 PM
  5. Focus on any of the text inputs with errors, type something more.
  6. Expected result: the inline error and highlight should disappear only for that input. Screen Shot 2021-09-13 at 5 04 37 PM
  7. Fill all fields of the form with valid values and input an invalid "Phone Number" like 123. Valid values:
    • Zip Code: 123456
    • Company website: https://test.com
    • Tax ID number: 123456789
    • Industry classification code: 123456
  8. Click "Save & continue"
  9. Expected result: We should see the loading transition (data is sent to back-end), then we should see the error modal with a message like "Please provide a valid Phone Number", and no fields should be highlighted. Screen Shot 2021-09-13 at 5 06 55 PM

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Mobile Web

Desktop

iOS

Android

Add props to receive error in ExpensiPicker
Set red outline based on the error received
Display optional error text in ExpensiPicker
@aldo-expensify aldo-expensify changed the title [WIP] Highlight all errors in VBA flow - Company step Highlight all errors in VBA flow - Company step Sep 9, 2021
@aldo-expensify aldo-expensify marked this pull request as ready for review September 9, 2021 22:05
@aldo-expensify aldo-expensify requested a review from a team as a code owner September 9, 2021 22:05
@MelvinBot MelvinBot requested review from Julesssss and removed request for a team September 9, 2021 22:05
@aldo-expensify
Copy link
Contributor Author

aldo-expensify commented Sep 9, 2021

Update: Removed WIP/Draft. Handle error outline for StatePicker.

@@ -80,58 +80,107 @@ class CompanyStep extends React.Component {
'password',
'companyPhone',
];

// Keys in this.errorTranslationKeys are associated to inputs, they are a subset of the keys found in this.state
Copy link
Contributor

@Julesssss Julesssss Sep 10, 2021

Choose a reason for hiding this comment

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

NAB: I read this comment a few times and couldn't understand the purpose until I looked at usages in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it, is it better or worse? :P

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

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

I think there's some potential to improve ExpensiTextInput further and to delegate some of the error logic to the component, but this isn't an N6 blocker.

Comment on lines 17 to 18
/** Should the input be styled for errors */
hasError: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: It kinda feels like we're tying the prop to UI here, I would have thought the prop should simply describe state, rather than what we do with that state. But I could be wrong, and this is not a huge deal I guess.

Copy link
Contributor

Choose a reason for hiding this comment

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

What would the alternative be here? FWIW this seems to be how we're handling things in the ExpensiTextInput

/** Error text to display */
errorText: PropTypes.string,
/** Should the input be styled for errors */
hasError: PropTypes.bool,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NAB: It kinda feels like we're tying the prop to UI here, I would have thought the prop should simply describe state, rather than what we do with that state. But I could be wrong, and this is not a huge deal I guess.

Are you saying that the comment should be updated? or the itself prop is not well defined?

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

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

Tested web and the forms are working as expected.

I see a few improvements (scroll to error on mobile, highlight API forms), but I see that we're aware of this and still discussing here.

@Julesssss
Copy link
Contributor

Hey @marcaaron, did you want (and have time) to review this PR? If yes then I'll await your review.

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.

Looking good ! Left some comments / notes.

Comment on lines 17 to 18
/** Should the input be styled for errors */
hasError: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

What would the alternative be here? FWIW this seems to be how we're handling things in the ExpensiTextInput

/** Error text to display */
errorText: PropTypes.string,
/** Should the input be styled for errors */
hasError: PropTypes.bool,

src/components/ExpensiPicker.js Outdated Show resolved Hide resolved
src/components/ExpensiTextInput/propTypes.js Show resolved Hide resolved
src/components/StatePicker.js Outdated Show resolved Hide resolved
src/pages/ReimbursementAccount/CompanyStep.js Outdated Show resolved Hide resolved
src/pages/ReimbursementAccount/CompanyStep.js Outdated Show resolved Hide resolved
src/pages/ReimbursementAccount/CompanyStep.js Outdated Show resolved Hide resolved
src/pages/ReimbursementAccount/CompanyStep.js Outdated Show resolved Hide resolved
value={this.state.addressState}
hasError={this.getErrors().addressState}
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 going to add a label for this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just putting the red outline because there is little space under the StatePicker, do you want me to test how it would look with the error text there?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we show the inline message in the space here?

2021-09-13_11-19-48

Any thoughts @shawnborton ? Or should we just let this one go?

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

aldo-expensify commented Sep 13, 2021

Update: I decided to stick to leaving the "Save & continue" button disabled if there is any empty field (including terms and conditions checkbox). Why?:

  • To implement the "Save & continue" always enabled behaviour I needed to add the error text and outline for another component that doesn't have it yet: CheckboxWithLabel.
  • Adding the error outline + text to CheckboxWithLabel would probably require some feedback from a designer.
  • I was already adding error text + outline support for ExpensiPicker and StatePicker which was feeling like going too far with this PR.

Considering this, the following changed:

  • This PR is sticking to the strategy of only enabling the "Save & continue" button if there is NO empty field. This is consistent with the "add manually bank account step"
  • Error text + outline for ExpensiPicker and StatePicker is not necessary in this PR anymore, so it was removed
  • I'm still outlining and showing all errors together for inputs of type ExpensiTextInput

The following should be addressed in a future PR:

  • Add support for error text + outline for ExpensiPicker, StatePicker and CheckboxWithLabel
  • Make the "Save & continue" button always enabled

We have a GH issue and @pecanoro has a PR already on the way for it.

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.

Just a couple more comments. This is looking really great.

src/pages/ReimbursementAccount/CompanyStep.js Show resolved Hide resolved
src/pages/ReimbursementAccount/CompanyStep.js Outdated Show resolved Hide resolved
src/pages/ReimbursementAccount/CompanyStep.js Outdated Show resolved Hide resolved
return !_.isEmpty(value);
}
return Boolean(value);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB, I like this method. My one hesitation is whether the boolean case makes the name confusing b.c. a boolean with a false is technically "present" it's just false.

For the boolean case we are just returning the boolean again not whether it has a value or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had the same concern about booleans, maybe it would be cleaner to consider true and false as present. Then, we just handle the case of the "terms and conditions" checkbox without this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, made a small change here. false and true (booleans) are considered "present". Therefore, we are not using this function to test the value for hasNoConnectionToCannabis.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok cool I think this works for now. Probably we will want to think about this some more when we build a more generic form component and need a generic way to test that a field marked as "required" when a boolean will be tested for "existing" and "true".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok cool I think this works for now. Probably we will want to think about this some more when we build a more generic form component and need a generic way to test that a field marked as "required" when a boolean will be tested for "existing" and "true".

Yes, I think this is a good idea. Postpone thinking further about this until we have more cases or a more generic.

@marcaaron
Copy link
Contributor

I was already adding error text + outline support for ExpensiPicker and StatePicker which was feeling like going too far with this PR.

Ok good call. Sounds like this is a blocker for this issue to remove the disabled feature so we can maybe take care of this there.

Error text + outline for ExpensiPicker and StatePicker is not necessary in this PR anymore, so it was removed

Just to clarify, since we are not able to add this for the checkbox you'd think it would be better to add inline handling later as well?

@aldo-expensify
Copy link
Contributor Author

aldo-expensify commented Sep 14, 2021

Just to clarify, since we are not able to add this for the checkbox you'd think it would be better to add inline handling later as well?

Yes. In this PR we are keeping the "Save & continue" button disabled if there is any empty field. The "Save & continue" button doesn't become enabled until we have chosen all states (StatePicker) and the company type (ExpensiPicker), so these highlights were not going to be used/shown under this configuration. Same thing applies for the inline highlight of the checkbox component.

I think these things should be added together with making the "Save & continue" button always enabled, because then we will have the case where we want to inline an error in those inputs.

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. I only really have one small note left about the comment in the isValuePresent method. Once that is resolved I'm ready to merge.

}

Copy link
Contributor

Choose a reason for hiding this comment

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

NAB, removing these new lines seems unnecessary. I like them personally since things are less visually compressed, but that's just my opinion and there are no style rules about this as far as I know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got mixed up with the php guidelines. I assumed that a similar rule would apply here... reverting!

@aldo-expensify
Copy link
Contributor Author

Update:

  • isValuePresent became isRequiredFulfilled
  • isRequiredFulfilled returns false if value is false
  • Added hasNoConnectionToCannabis to required fields in CompanyStep.js

@marcaaron
Copy link
Contributor

Going to merge this so we can keep plugging away at the remaining steps. @Julesssss thanks for your review and please let us know if you've got any additional comments that we can follow up on if they were not resolved.

@marcaaron marcaaron merged commit 0f4abe1 into main Sep 14, 2021
@marcaaron marcaaron deleted the aldo_show-all-errors-vba-company branch September 14, 2021 22:12
@OSBotify
Copy link
Contributor

✋ 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

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

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Jag96 in version: 1.0.99-4 🚀

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.

4 participants