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

[HOLD for payment 2024-08-02] [$250] Login - Focus is shown on login field briefly and scrolled down #45571

Closed
2 of 6 tasks
izarutskaya opened this issue Jul 17, 2024 · 18 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 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Jul 17, 2024

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.8
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4729962
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

Pre- condition

  1. Log out of app and clear history and cache
  2. Go to https://staging.new.expensify.com/home

Expected Result:

Focus should be on top login screen and must not scrolled down

Actual Result:

Focus is shown on login field briefly and scrolled down.

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

Bug6544764_1721200290708.az_recorder_20240717_123451_compress_1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012686d622c878c512
  • Upwork Job ID: 1813517786978772508
  • Last Price Increase: 2024-07-17
Issue OwnerCurrent Issue Owner: @mallenexpensify
@izarutskaya izarutskaya added DeployBlockerCash This issue or pull request should block deployment Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. DeployBlocker Indicates it should block deploying the API labels Jul 17, 2024
Copy link

melvin-bot bot commented Jul 17, 2024

Triggered auto assignment to @Julesssss (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Jul 17, 2024

Triggered auto assignment to @mallenexpensify (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.

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Jul 17, 2024
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@izarutskaya
Copy link
Author

We think this issue might be related to the #vip-vsb

@izarutskaya
Copy link
Author

izarutskaya commented Jul 17, 2024

Production

Screen_Recording_20240717_102451_Chrome.mp4

@Julesssss
Copy link
Contributor

I can reproduce, making external

@Julesssss Julesssss added Daily KSv2 External Added to denote the issue can be worked on by a contributor and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 DeployBlocker Indicates it should block deploying the API labels Jul 17, 2024
@melvin-bot melvin-bot bot changed the title Login - Focus is shown on login field briefly and scrolled down [$250] Login - Focus is shown on login field briefly and scrolled down Jul 17, 2024
Copy link

melvin-bot bot commented Jul 17, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 17, 2024
Copy link

melvin-bot bot commented Jul 17, 2024

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

@Julesssss
Copy link
Contributor

This PR seems a likely cause. I am hesitant to revert as it fixes many issues.

@bernhardoj
Copy link
Contributor

Proposal

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

The login page is scrolled down.

What is the root cause of that problem?

This happens after #44932. In that PR, we update the focus trap initial focus logic so that if there is already a focused element, the initial focus won't fire.

initialFocus: (focusTrapContainers) => {
const isFocusedElementInsideContainer = focusTrapContainers?.some((container) => container.contains(document.activeElement));
if (isFocusedElementInsideContainer) {
return false;
}
return undefined;
},

However, on the login page, none of the elements is already focused, so the initial focus fires and focuses on the footer text link instead of the login field. Why? That's because the login form is wrapped with withOnyx which delays the input field rendering, so the initial focus found the footer text link first.

export default withToggleVisibilityView(
withOnyx<BaseLoginFormProps, BaseLoginFormOnyxProps>({
account: {key: ONYXKEYS.ACCOUNT},
credentials: {key: ONYXKEYS.CREDENTIALS},
closeAccount: {key: ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM},
})(forwardRef(BaseLoginForm)),
);

On the login page, we actually have a logic to auto-focus the login input field, but it's only for desktop/web. For mWeb/native, we won't auto-focus the input field.

if (!canFocusInputOnScreenFocus() || !input.current || !isVisible || !isFocused) {
return;
}
let focusTimeout: NodeJS.Timeout;
if (isInNarrowPaneModal) {
focusTimeout = setTimeout(() => input.current?.focus(), CONST.ANIMATED_TRANSITION);
} else {
input.current.focus();
}
return () => clearTimeout(focusTimeout);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps -- we just want to call this function when component is mounted
}, []);

Previously, we always ignored the focus trap initial focus for the login page.

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

Bring back the previous logic that ignores the focus-trap initial focus for login page.

const SCREENS_WITH_AUTOFOCUS: string[] = [SCREENS.SIGN_IN_ROOT];

function getScreenWithAutofocus(isAuthenticated: boolean) {
    if (!isAuthenticated) {
        return [...SCREENS_WITH_AUTOFOCUS, NAVIGATORS.BOTTOM_TAB_NAVIGATOR];
    }
    return SCREENS_WITH_AUTOFOCUS;
}

if (screensWithAutofocus.includes(activeRouteName) || isFocusedElementInsideContainer) {
    return false;

The isFocusedElementInsideContainer logic works well to prevent the initial focus from happening when there is already a focused element, but there is a case where we don't want an initial focus at all, such as sign-in page.

@suneox
Copy link
Contributor

suneox commented Jul 17, 2024

I’d like to take a look at this issue, as it’s an edge case resulting from the change that removed SCREENS_WITH_AUTOFOCUS maintenance at this PR. We just added the condition check canFocusInputOnScreenFocus to prevent initialFocus because if the condition check can't focus on screen, we don’t need to set the initial focus.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jul 17, 2024
@mallenexpensify
Copy link
Contributor

mallenexpensify commented Jul 19, 2024

@suneox drafted the (likely) offending PR so assigning to them for now.

@bernhardoj thanks for the proposal. It's possible compensation might be due, we'll address once the PR for the fix has hit production.

@mallenexpensify mallenexpensify added Daily KSv2 and removed Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2 labels Jul 19, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jul 26, 2024
@melvin-bot melvin-bot bot changed the title [$250] Login - Focus is shown on login field briefly and scrolled down [HOLD for payment 2024-08-02] [$250] Login - Focus is shown on login field briefly and scrolled down Jul 26, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 26, 2024
Copy link

melvin-bot bot commented Jul 26, 2024

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

Copy link

melvin-bot bot commented Jul 26, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.12-0 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 2024-08-02. 🎊

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

  • @DylanDylann requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Jul 26, 2024

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:

  • [@DylanDylann] The PR that introduced the bug has been identified. Link to the PR:
  • [@DylanDylann] 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:
  • [@DylanDylann] 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:
  • [@DylanDylann] Determine if we should create a regression test for this bug.
  • [@DylanDylann] 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.
  • [@mallenexpensify] 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 labels Aug 1, 2024
@mallenexpensify mallenexpensify removed their assignment Aug 1, 2024
@mallenexpensify mallenexpensify added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Aug 1, 2024
Copy link

melvin-bot bot commented Aug 1, 2024

Triggered auto assignment to @puneetlath (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.

@mallenexpensify
Copy link
Contributor

@puneetlath I'm off til Monday afternoon, can you help with payment here? Thx

@mallenexpensify mallenexpensify self-assigned this Aug 1, 2024
@s77rt
Copy link
Contributor

s77rt commented Aug 2, 2024

No payment due here. Let's close

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 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

8 participants