Skip to content

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

Closed

Description

@kavimuru

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 21, 2023
  2. MelvinBot commented on Apr 21, 2023

    @MelvinBot
    Contributor

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

  3. MelvinBot commented on Apr 21, 2023

    @MelvinBot
    Contributor

    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
  4. dhairyasenjaliya commented on Apr 21, 2023

    @dhairyasenjaliya
    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)
  5. PrashantMangukiya commented on Apr 21, 2023

    @PrashantMangukiya
    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
  6. MelvinBot commented on Apr 21, 2023

    @MelvinBot
    Contributor

    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.

  7. strepanier03 commented on Apr 22, 2023

    @strepanier03
    Contributor

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

    image

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 22, 2023
  9. 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[/+] on Apr 22, 2023
  10. MelvinBot commented on Apr 22, 2023

    @MelvinBot
    Contributor
  11. MelvinBot commented on Apr 22, 2023

    @MelvinBot
    Contributor

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

  12. MelvinBot commented on Apr 22, 2023

    @MelvinBot
    Contributor

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

  13. 18 remaining items

  14. strepanier03 commented on May 4, 2023

    @strepanier03
    Contributor

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

  15. strepanier03 commented on May 4, 2023

    @strepanier03
    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.

  16. PrashantMangukiya commented on May 4, 2023

    @PrashantMangukiya
    Contributor

    @strepanier03 Offer accepted on Upwork.

  17. strepanier03 commented on May 4, 2023

    @strepanier03
    Contributor

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

  18. PrashantMangukiya commented on May 4, 2023

    @PrashantMangukiya
    Contributor

    @strepanier03 Received, Thank you.

  19. Santhosh-Sellavel commented on May 5, 2023

    @Santhosh-Sellavel
    Collaborator

    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!

  20. Santhosh-Sellavel commented on May 7, 2023

    @Santhosh-Sellavel
    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

  21. Santhosh-Sellavel commented on May 7, 2023

    @Santhosh-Sellavel
    Collaborator

    @strepanier03 Accepted offer thanks!

  22. strepanier03 commented on May 8, 2023

    @strepanier03
    Contributor

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

    Thank you everyone!

  23. 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[/+] on May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions