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

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

Closed
1 of 6 tasks
kavimuru opened this issue Apr 21, 2023 · 26 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented Apr 21, 2023

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?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

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

Screen.Recording.2023-04-20.at.7.36.41.PM.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
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 21, 2023
@MelvinBot
Copy link

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

@MelvinBot
Copy link

MelvinBot commented Apr 21, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@dhairyasenjaliya
Copy link
Contributor

Proposal

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

  • Leading whitespaces aren’t truncated while saving email/phone number in new contact method page

What is the root cause of that problem?

  • We are adding trim only while validating the submit button rather than validating for submit button we should validate at time of text change only so this will make sure to remove all white space before storing/displaying actualy value

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

  • On NewContactMethodPage.js -> we need to trim value at onLoginChange() and remove trim from validateForm() since we are limiting the white space at first place so need to to extra trim for submit button

Changes

        onLoginChange(login) {
+        const validate = login.trim();
       this.setState({login:validate});
   }

   /**
   * Determine whether the form is valid
   *
   * @returns {Boolean}
   */
validateForm() {
-        const login = this.state.login.trim();
+       const login = this.state.login
       const phoneLogin = LoginUtils.getPhoneNumberWithoutSpecialChars(login);

       return (Permissions.canUsePasswordlessLogins(this.props.betas) || this.state.password)
           && (Str.isValidEmail(login) || Str.isValidPhone(phoneLogin));
   }      

What alternative solutions did you explore? (Optional)

  • We could also display an error message bottom of each input (this is not the scope of this issue but we can add it here)

@PrashantMangukiya
Copy link
Contributor

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.

onLoginChange(login) {
this.setState({login});
}

Also during submitForm() we do not trim this.state.login as shown below,

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

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.

Email.mov

Truncate leading/trailing space from Phone and allow space in between phone number.

Phone.mov
Phone2.mov

@MelvinBot
Copy link

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
Copy link
Contributor

strepanier03 commented Apr 22, 2023

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

image

@strepanier03 strepanier03 added the External Added to denote the issue can be worked on by a contributor label Apr 22, 2023
@melvin-bot melvin-bot bot changed the title Leading whitespaces aren’t truncated while saving email/phone number in new contact method page [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page Apr 22, 2023
@MelvinBot
Copy link

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

@MelvinBot
Copy link

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

@MelvinBot
Copy link

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 22, 2023
@MelvinBot
Copy link

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

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented Apr 22, 2023

@PrashantMangukiya's Proposal LGTM, straight forward change!

C+ Reviewed
🎀 👀 🎀

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 22, 2023
@MelvinBot
Copy link

📣 @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
Copy link
Collaborator

Santhosh-Sellavel commented Apr 22, 2023

@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
Copy link
Contributor

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

@melvin-bot melvin-bot bot changed the title [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page [HOLD for payment 2023-05-03] [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page Apr 26, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 26, 2023
@MelvinBot
Copy link

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

@MelvinBot
Copy link

MelvinBot commented Apr 26, 2023

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

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

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:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@MelvinBot
Copy link

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:

  • [@Santhosh-Sellavel] The PR that introduced the bug has been identified. Link to the PR:
  • [@Santhosh-Sellavel] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@Santhosh-Sellavel] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@Santhosh-Sellavel] Determine if we should create a regression test for this bug.
  • [@Santhosh-Sellavel] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@strepanier03] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 Daily KSv2 labels May 2, 2023
@strepanier03
Copy link
Contributor

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

@strepanier03
Copy link
Contributor

@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
Copy link
Contributor

@strepanier03 Offer accepted on Upwork.

@strepanier03
Copy link
Contributor

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

@PrashantMangukiya
Copy link
Contributor

@strepanier03 Received, Thank you.

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented May 5, 2023

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
Copy link
Collaborator

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
Copy link
Collaborator

@strepanier03 Accepted offer thanks!

@strepanier03
Copy link
Contributor

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

Thank you everyone!

@strepanier03 strepanier03 changed the title [HOLD for payment 2023-05-03] [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page [PAID] [$1000] Leading whitespaces aren’t truncated while saving email/phone number in new contact method page May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

7 participants