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

[Due for payment 2025-02-13] [$250] Log in - Login page scroll to top on change language #55368

Closed
3 of 8 tasks
lanitochka17 opened this issue Jan 16, 2025 · 26 comments
Closed
3 of 8 tasks
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

@lanitochka17
Copy link

lanitochka17 commented Jan 16, 2025

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: 9.0.86-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

Preconditions: User should be logged out

  1. Open https://staging.new.expensify.com/
  2. Scroll to bottom
  3. Change language

Expected Result:

Page position should not be changed

Actual Result:

Login page scroll to top

Workaround:

Unknown

Platforms:

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

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6698620_1734580924023.295.mp4

View all open jobs on GitHub

555555555.mp4
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021881832199834454313
  • Upwork Job ID: 1881832199834454313
  • Last Price Increase: 2025-01-21
  • Automatic offers:
    • linhvovan29546 | Contributor | 105899583
Issue OwnerCurrent Issue Owner: @johncschuster
@lanitochka17 lanitochka17 added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Jan 16, 2025
Copy link

melvin-bot bot commented Jan 16, 2025

Triggered auto assignment to @johncschuster (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

Copy link
Contributor

⚠️ @Shahidullah-Muffakir Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

1 similar comment
Copy link
Contributor

⚠️ @Shahidullah-Muffakir Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

@mohit6789
Copy link
Contributor

mohit6789 commented Jan 16, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-01-16 21:58:56 UTC.

Proposal

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

Login page scroll to top on change language

What is the root cause of that problem?

Because we passed prevPreferredLocale in dependancy array of useEffect here it rerun whenever prevPreferredLocale value change. prevPreferredLocale is not state/props so we should not pass it in dependancy array.

const prevPreferredLocale = usePrevious(preferredLocale);

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

Remove prevPreferredLocale from dependancy array fix this issue.

}, [welcomeHeader, welcomeText, prevPreferredLocale, preferredLocale]);

Note: We should not remove this block because welcomeHeader and welcomeText are change based on some logic from here. So we should scroll to top whenever welcomeHeader and welcomeText are changed.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

What alternative solutions did you explore? (Optional)

@drminh2807
Copy link
Contributor

Proposal

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

Log in - Login page scroll to top on change language

What is the root cause of that problem?

Here’s a rewritten version of your text with improved clarity and flow:

The SignInPageLayout component rerenders twice when the locale changes because both navigateFocus and children are updated. As a result, const prevPreferredLocale = usePrevious(preferredLocale); doesn't behave as intended.

Evidence of this can be observed by commenting out both properties—while the UI may display hidden components, the rerendering issue no longer occurs.

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

To address this, we should use an alternative method to track prevPreferredLocale.

useEffect(() => {
if (prevPreferredLocale !== preferredLocale) {
return;
}
scrollPageToTop();
}, [welcomeHeader, welcomeText, prevPreferredLocale, preferredLocale]);

    const prevPreferredLocale = useRef(preferredLocale);
    useEffect(() => {
        if (prevPreferredLocale.current !== preferredLocale) {
            prevPreferredLocale.current = preferredLocale;
            return;
        }

        scrollPageToTop();
    }, [welcomeHeader, welcomeText, preferredLocale]);

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A

What alternative solutions did you explore? (Optional)

N/A

@melvin-bot melvin-bot bot added the Overdue label Jan 20, 2025
Copy link

melvin-bot bot commented Jan 20, 2025

@johncschuster Whoops! This issue is 2 days overdue. Let's get this updated quick!

@johncschuster johncschuster added the External Added to denote the issue can be worked on by a contributor label Jan 21, 2025
Copy link

melvin-bot bot commented Jan 21, 2025

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

@melvin-bot melvin-bot bot changed the title Log in - Login page scroll to top on change language [$250] Log in - Login page scroll to top on change language Jan 21, 2025
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 21, 2025
Copy link

melvin-bot bot commented Jan 21, 2025

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

@melvin-bot melvin-bot bot removed the Overdue label Jan 21, 2025
@huult
Copy link
Contributor

huult commented Jan 22, 2025

Proposal

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

Login page scroll to top on change language

What is the root cause of that problem?

The reason SignInPageLayout triggers a re-render twice when the locale is changed is that prevPreferredLocale gets assigned both the old and new values. As a result, when prevPreferredLocale holds the old value, the condition to scroll to the top is validated, causing this issue

function SignInPageLayout(

and the component re-renders due to stale references if signInPageLayoutRef.current changes after the assignment

scrollPageToTop={signInPageLayoutRef.current?.scrollPageToTop}

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

To resolve this issue, use an arrow function that wraps the scrollPageToTop call. This ensures signInPageLayoutRef.current is accessed at execution time, keeping the reference up-to-date and preventing SignInPageLayout from triggering unnecessary re-renders

scrollPageToTop={signInPageLayoutRef.current?.scrollPageToTop}

update to:

    scrollPageToTop={() => {
        signInPageLayoutRef.current?.scrollPageToTop();
    }}
POC
Screen.Recording.2025-01-22.at.15.53.08.mp4

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

This is a UI bug and does not require testing.

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@hungvu193
Copy link
Contributor

Update: I'll review the proposals tomorrow.

@hungvu193
Copy link
Contributor

Still under reviewing

@linhvovan29546
Copy link
Contributor

linhvovan29546 commented Jan 24, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-01-24 10:56:54 UTC.

Proposal

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

Log in - Login page scroll to top on change language

What is the root cause of that problem?

This issue occurs because the language change triggers a useEffect in the code.

useEffect(() => {
if (prevPreferredLocale !== preferredLocale) {
return;
}
scrollPageToTop();
}, [welcomeHeader, welcomeText, prevPreferredLocale, preferredLocale]);

When the welcomeHeader or welcomeText changes, it causes the page to scroll to the top. This behavior seems to be related to a previous issue that was fixed in PR #21815.
However, the issue has resurfaced because the component re-renders twice, which leads to the condition prevPreferredLocale !== preferredLocale evaluating to false, which leads to the page scrolling to the top

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

I suggest removing the useEffect

useEffect(() => {
if (prevPreferredLocale !== preferredLocale) {
return;
}
scrollPageToTop();
}, [welcomeHeader, welcomeText, prevPreferredLocale, preferredLocale]);

Why should we remove it?
This useEffect was introduced in PR #17445 to ensure the page scrolls to the top when clicking actions like "Create A New Account," "Log In," "Go Back," or "Forget." However, this functionality is now handled by a separate implementation introduced in PR #33743, making this useEffect redundant.

POC
Before After
page-scroll-to-top-before.mp4
page-scoll-to-top-after.mp4

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@hungvu193
Copy link
Contributor

Thanks everyone for the proposals. After checking carefully. I agree with @linhvovan29546 's proposal here. We should remove this block of code. It was added to solve #16357 but it was resolved with #33743 and we don't need it anymore.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jan 26, 2025

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

@robertjchen
Copy link
Contributor

Thanks for the detailed review and proposals. Let's go with @linhvovan29546 's proposal 👍

@melvin-bot melvin-bot bot added the Overdue label Jan 29, 2025
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 29, 2025
Copy link

melvin-bot bot commented Jan 29, 2025

📣 @linhvovan29546 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer 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 📖

@melvin-bot melvin-bot bot removed the Overdue label Jan 29, 2025
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jan 29, 2025
@linhvovan29546
Copy link
Contributor

PR is ready for review!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Feb 6, 2025
@melvin-bot melvin-bot bot changed the title [$250] Log in - Login page scroll to top on change language [Due for payment 2025-02-13] [$250] Log in - Login page scroll to top on change language Feb 6, 2025
Copy link

melvin-bot bot commented Feb 6, 2025

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Feb 6, 2025
Copy link

melvin-bot bot commented Feb 6, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.94-25 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 2025-02-13. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Feb 6, 2025

@hungvu193 @johncschuster @hungvu193 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@johncschuster
Copy link
Contributor

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] 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:

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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:

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

Regression Test Proposal Template
  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Precondition:

Test:

Do we agree 👍 or 👎

@johncschuster
Copy link
Contributor

Payment Summary

Contributor: @linhvovan29546 paid $250 via Upwork (will be paid after BZ Checklist and regression threshold window has been crossed)
Contributor+: @hungvu193 owed $250 via NewDot

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Feb 13, 2025
Copy link

melvin-bot bot commented Feb 13, 2025

@robertjchen @johncschuster @hungvu193 @linhvovan29546 this issue is now 4 weeks old, please consider:

  • Finding a contributor to fix the bug
  • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
  • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

Thanks!

@hungvu193
Copy link
Contributor

hungvu193 commented Feb 13, 2025

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other: We changed the design and this bug is happening again.

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] 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: We don't have offending PR for this issue, the behavior was changed and the block of code that we added to fix the previous issue is now redundant.

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: N/A

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

Test:

  1. Logout if you're login.
  2. Scroll down to the bottom and change the language.
  3. Verify that Login Page doesn't scroll to top.

Do we agree 👍 or 👎

@johncschuster
Copy link
Contributor

johncschuster commented Feb 13, 2025

Payment has been issued via Upwork to @linhvovan29546! @hungvu193, please request payment via ND! (Summary here)

@garrettmknight
Copy link
Contributor

$250 approved for @hungvu193

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

9 participants