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

[$500] Login - Validation errors appears when cursor lost focus, a number or a letter is entered #31434

Closed
6 tasks done
izarutskaya opened this issue Nov 16, 2023 · 11 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@izarutskaya
Copy link

izarutskaya commented Nov 16, 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!


Version Number: 1.4.0-0
Reproducible in staging?: Y
Reproducible in production?: N
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
Expensify/Expensify Issue URL:
Issue reported by: Applause-Internal Team
Slack conversation: @

Action Performed:

  1. Open the testing desktop app
  2. Make the login field to lose cursor focus (click outside the login field)
  3. Observe error
  4. Enter any letter/number

Expected Result:

Validation error should not appear once field is lost focus, also validation errors for email or number should not appear immediately once a letter or a number is typed. Ideally the validation error should appear after user clicks on continue button.

Actual Result:

Validation error appears once cursor focus is lost and when a user types any letter or number

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6278889_1700129917143.Validation_error.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0116b9e73562a30f5b
  • Upwork Job ID: 1725116807168163840
  • Last Price Increase: 2023-11-16
@izarutskaya izarutskaya added DeployBlockerCash This issue or pull request should block deployment External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 16, 2023
@melvin-bot melvin-bot bot changed the title Login - Validation errors appears when cursor lost focus, a number or a letter is entered [$500] Login - Validation errors appears when cursor lost focus, a number or a letter is entered Nov 16, 2023
Copy link

melvin-bot bot commented Nov 16, 2023

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

Copy link

melvin-bot bot commented Nov 16, 2023

Job added to Upwork: https://www.upwork.com/jobs/~0116b9e73562a30f5b

Copy link

melvin-bot bot commented Nov 16, 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

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

melvin-bot bot commented Nov 16, 2023

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

@izarutskaya
Copy link
Author

Not reproduce in prod

Recording.1877.mp4

@esh-g
Copy link
Contributor

esh-g commented Nov 16, 2023

Regression from #30563

@esh-g
Copy link
Contributor

esh-g commented Nov 16, 2023

I think it may be expected... @dukenv0307

@dukenv0307
Copy link
Contributor

It's expected.

@HardikChoudhary24
Copy link
Contributor

Proposal

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

  • Validation errors appears when cursor lost focus, a number or a letter is entered

What is the root cause of that problem?

  • This issue arises due to the way we are handling validation in validate function. We are directly setting the error if the string is empty.
  • Also we are using firstBlurred to call the validate function whenever the text input is changed after the first validation which causes the validation error to appear immediately once a letter or a number is typed.
    const validate = useCallback(
    (value) => {
    const loginTrim = value.trim();
    if (!loginTrim) {
    setFormError('common.pleaseEnterEmailOrPhoneNumber');
    return false;
    }
    const phoneLogin = LoginUtils.appendCountryCode(LoginUtils.getPhoneNumberWithoutSpecialChars(loginTrim));
    const parsedPhoneNumber = parsePhoneNumber(phoneLogin);
    if (!Str.isValidEmail(loginTrim) && !parsedPhoneNumber.possible) {
    if (ValidationUtils.isNumericWithSpecialChars(loginTrim)) {
    setFormError('common.error.phoneNumber');
    } else {
    setFormError('loginForm.error.invalidFormatEmailLogin');
    }
    return false;
    }
    setFormError(null);
    return true;
    },
    [setFormError],
    );

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

  • To address this problem, we can resolve it by simply adding a check to see whether the input is empty and also this is to be done only if the form is not submitted, hence we need to modify the function by adding an extra parameter to check whether the form is submitted or not.
  • Also we need to change the firstBlurred to false if the form input becomes empty and user starts to enter text again. This will ensure that the error does not appear until the user submits the form and if the user submits the form with input having error, the error will not go away until all the errors are removed(This is done to ensure that the solution for [HOLD for payment 2023-11-27] [$500] Login - When user changes CAPS letter to small error cleared but reappears on tapping continue #29640 is preserved)
const validate = useCallback(
        (value, formSubmitted = false) => {
            const loginTrim = value.trim();

            if (!formSubmitted && loginTrim.length === 0) {
                setFormError(null);
                firstBlurred.current = false;
                return true;
            }
            if (!loginTrim) {
                setFormError('common.pleaseEnterEmailOrPhoneNumber');
                return false;
            }

            const phoneLogin = LoginUtils.appendCountryCode(LoginUtils.getPhoneNumberWithoutSpecialChars(loginTrim));
            const parsedPhoneNumber = parsePhoneNumber(phoneLogin);

            if (!Str.isValidEmail(loginTrim) && !parsedPhoneNumber.possible) {
                if (ValidationUtils.isNumericWithSpecialChars(loginTrim)) {
                    setFormError('common.error.phoneNumber');
                } else {
                    setFormError('loginForm.error.invalidFormatEmailLogin');
                }
                return false;
            }

            setFormError(null);
            return true;
        },
        [setFormError],
    );

Result

newsample2.mov

What alternative solutions did you explore? (Optional)
N/A

@aimane-chnaif
Copy link
Contributor

aimane-chnaif commented Nov 16, 2023

@mallenexpensify
Copy link
Contributor

Thanks, going to close.
Thanks too to @HardikChoudhary24 for your proposal, even though we're deciding not to move forward with an update here.

@roryabraham roryabraham removed the DeployBlockerCash This issue or pull request should block deployment label Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

8 participants