Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.33k stars 2.76k forks source link

[PAID] [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page #17770

Closed kavimuru closed 1 year ago

kavimuru commented 1 year ago

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. Go to Settings -> Profile -> contact methods
  2. Click on new contact methods
  3. Add email with spaces at front e.g “ sharmashim123@gmail.com
  4. Type in password and save
  5. Now, it should redirect to contact methods page
  6. Notice that the leading spaces aren’t removed while displaying email/phone number

Expected Result:

Leading or trailing spaces should be removed and email.phone number should be displayed accordingly for better UI

Actual Result :

Leading spaces makes improper indentation while display.

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.3 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

https://user-images.githubusercontent.com/43996225/233529701-d5974fa3-e27f-4ce8-b726-f489357e43a3.mov

Untitled

Expensify/Expensify Issue URL: Issue reported by: @ashimsharma10 Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1681998814607449

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b41c774d839dccd0
  • Upwork Job ID: 1649571325356744704
  • Last Price Increase: 2023-04-22
MelvinBot commented 1 year ago

Triggered auto assignment to @strepanier03 (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

MelvinBot commented 1 year ago

Bug0 Triage Checklist (Main S/O)

dhairyasenjaliya commented 1 year ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

What is the root cause of that problem?

What changes do you think we should make in order to solve the problem?

What alternative solutions did you explore? (Optional)

PrashantMangukiya commented 1 year ago

Proposal

Posting proposal early as per new guidelines

Please re-state the problem that we are trying to solve in this issue.

Leading whitespaces aren not truncated while saving email/phone number in new contact method page.

What is the root cause of that problem?

We can see within onLoginChange() we do not trim login before save to state, so login value will be with leading and trailing space if entered. https://github.com/Expensify/App/blob/4f7cfdb53216185ac7e825127b3be2f8238340fd/src/pages/settings/Profile/Contacts/NewContactMethodPage.js#L68-L70

Also during submitForm() we do not trim this.state.login as shown below, https://github.com/Expensify/App/blob/4f7cfdb53216185ac7e825127b3be2f8238340fd/src/pages/settings/Profile/Contacts/NewContactMethodPage.js#L85-L92

So User.addNewContactMethodAndNavigate() method will save login value with leading and trailing space. This is the root cause of the problem.

What changes do you think we should make in order to solve the problem?

To solve this we can think to trim login while save to state at line 69 within onLoginChange().

But it is not advisable because user may enter Email Or Phone number within login field. So if user typing email then trim() during save to state will be ok, because generally blank space not comes within email so user will not try to enter blank space within email.

But if user enter Phone number then user have habit to enter phone number like "123 4567 8901" i.e. with space. So if we trim value during onChange, then as soon as user type space within phone number onLoginChange() will trim space during save to state. So it will make bad user experience and user will not able to enter space within phone number.

So better approach is to trim login within submitForm() function and use trimmed login value for lodashGet() and addNewContactMethodAndNavigate() api. So modified submitForm() function code looks as shown below.

submitForm() {
    // Trim leading and trailing space from login
    const login = this.state.login.trim();

    // If this login already exists, just go back.
    if (lodashGet(this.props.loginList, login)) {
        Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHODS);
        return;
    }
    User.addNewContactMethodAndNavigate(login, this.state.password);
}

So this will solve the issue i.e. truncate leading/trailing white space from email or phone number, and allows to enter space within phone number. Result video attached below.

What alternative solutions did you explore? (Optional)

None.

Results #### Truncate leading/trailing space from email. https://user-images.githubusercontent.com/7823358/233578309-69a620dd-a2c2-4ce9-9abf-2213d26af09d.mov #### Truncate leading/trailing space from Phone and allow space in between phone number. https://user-images.githubusercontent.com/7823358/233578399-ebfc37b9-db7c-47b7-ad1c-073f595b47a1.mov https://user-images.githubusercontent.com/7823358/233585221-7127fade-4899-4976-86a8-5a1c5dd86f2a.mov
MelvinBot commented 1 year ago

Looks like something related to react-navigation may have been mentioned in this issue discussion.

As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our DeprecatedCustomActions.js files should not be accepted.

Feel free to drop a note in #expensify-open-source with any questions.

strepanier03 commented 1 year ago

Able to recreate following instructions but oddly I have the email listed twice, once with the extra spaced and once without.

image
MelvinBot commented 1 year ago

Job added to Upwork: https://www.upwork.com/jobs/~01b41c774d839dccd0

MelvinBot commented 1 year ago

Current assignee @strepanier03 is eligible for the External assigner, not assigning anyone new.

MelvinBot commented 1 year ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel (External)

MelvinBot commented 1 year ago

Triggered auto assignment to @luacmartins (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

Santhosh-Sellavel commented 1 year ago

@PrashantMangukiya's Proposal LGTM, straight forward change!

C+ Reviewed 🎀 👀 🎀

MelvinBot commented 1 year ago

📣 @PrashantMangukiya You have been assigned to this job by @luacmartins! Please apply to this job in Upwork and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻 Keep in mind: Code of Conduct | Contributing 📖

Santhosh-Sellavel commented 1 year ago

@Santhosh-Sellavel @luacmartins If we allow space on the phone number then case I think the issue will remain the same for the phone right?

It won't create the current issue, we are just trying to trim out leading and trailing space. So we are good here.

If you are talking about space between the phone numbers, that's an invalid phone number case we got already covered with showing an error. So we are good to go here too.

But restricting user input is bad UX.

PrashantMangukiya commented 1 year ago

@Santhosh-Sellavel @luacmartins Thank you. Applied to job on Upwork. I will prepare and submit PR within 3 hours asap.

MelvinBot commented 1 year ago

Reviewing label has been removed, please complete the "BugZero Checklist".

MelvinBot commented 1 year ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.3.5-6 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-05-03. :confetti_ball:

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

Speed bonus analysis: PR submitted on April 21 / PR merged on April 25 = Eligible

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

MelvinBot commented 1 year ago

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

strepanier03 commented 1 year ago

Just getting back from out of office and working to catch up on this now. I'll have an update shortly.

strepanier03 commented 1 year ago

@ashimsharma10 - I have hired you to a bug report job in Upwork.

@Santhosh-Sellavel and @PrashantMangukiya - I have hired you to the Upwork job as well.


@Santhosh-Sellavel - If you can finish the BZ checklist I'll update the comment and make any necessary reg test GHs.


I'll check in later today to pay what I can.

PrashantMangukiya commented 1 year ago

@strepanier03 Offer accepted on Upwork.

strepanier03 commented 1 year ago

@PrashantMangukiya and @ashimsharma10, I have paid you both via Upwork and closed contracts, thank you both!

PrashantMangukiya commented 1 year ago

@strepanier03 Received, Thank you.

Santhosh-Sellavel commented 1 year ago

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

cc: @luacmartins let me know if differ on anything, thanks!

Santhosh-Sellavel commented 1 year ago

Regression steps

From the PR itself looks good to me

  1. Go to Settings -> Profile -> Contact methods
  2. Click on "New contact method" button
  3. Add email/phone with leading and trailing spaces e.g “ test@test.com
  4. Tap Add button
  5. Now, it will go back to "Contact methods" page
  6. Verify that leading/trailing spaces does not show while display email/phone number.

👍 or 👎

cc: @luacmartins or @strepanier03

Santhosh-Sellavel commented 1 year ago

@strepanier03 Accepted offer thanks!

strepanier03 commented 1 year ago

REg test added and payment finalized. Going to close this now.

Thank you everyone!