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

[$250] Search - Report always auto scroll down after editing the expense from RHP #45434

Closed
6 tasks done
lanitochka17 opened this issue Jul 15, 2024 · 33 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Jul 15, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.7-3
Reproducible in staging?: Y
Reproducible in production?: N
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Submit two expenses
  4. Go to transaction thread of any of the expenses
  5. Send enough messages so that the thread is scrollable
  6. Scroll up and click on any field
  7. Edit the field and save it
  8. Note that the report does not auto scroll down
  9. Go to Search
  10. Open the report RHP for the same transaction thread
  11. Scroll up, click on any field, edit and save it

Expected Result:

The report will not auto scroll down after editing the expense

Actual Result:

The report always auto scroll down after editing the expense from RHP

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

Add any screenshot/video evidence

Bug6543218_1721078509312.scroll_4n41xoPu.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01254f76c66b3ced64
  • Upwork Job ID: 1812983922733611293
  • Last Price Increase: 2024-07-22
  • Automatic offers:
    • alitoshmatov | Reviewer | 103286918
@lanitochka17 lanitochka17 added DeployBlockerCash This issue or pull request should block deployment DeployBlocker Indicates it should block deploying the API labels Jul 15, 2024
Copy link

melvin-bot bot commented Jul 15, 2024

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

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.

@lanitochka17
Copy link
Author

We think that this bug might be related to #wave-collect - Release 1

@aldo-expensify
Copy link
Contributor

This behaviour is also in production, so removing the deploy blocker label:

Screen.Recording.2024-07-15.at.3.51.53.PM.mov

@aldo-expensify aldo-expensify added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 DeployBlocker Indicates it should block deploying the API labels Jul 15, 2024
Copy link

melvin-bot bot commented Jul 15, 2024

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

@aldo-expensify aldo-expensify added the External Added to denote the issue can be worked on by a contributor label Jul 15, 2024
@melvin-bot melvin-bot bot changed the title Search - Report always auto scroll down after editing the expense from RHP [$250] Search - Report always auto scroll down after editing the expense from RHP Jul 15, 2024
Copy link

melvin-bot bot commented Jul 15, 2024

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

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

melvin-bot bot commented Jul 15, 2024

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

@bernhardoj
Copy link
Contributor

Proposal

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

The report chat list always scroll to bottom when editing the money request info if we open it from the search page.

What is the root cause of that problem?

When we open the report screen from the search page, it's inside an RHP navigator. In RHP navigator, a previous screen is hidden, that is the display is set to 'none' (you can check this yourself from the element inspector). In our case, when we open the report RHP, and then open the description page, the report RHP is hidden.

The list in the report screen uses a custom FlatList which sets up a mutation observer. The mutation observer will scroll to the last scroll offset if it's different than the current offset.

const mutationObserver = new MutationObserver(() => {
// This needs to execute after scroll events are dispatched, but
// in the same tick to avoid flickering. rAF provides the right timing.
requestAnimationFrame(() => {
// Chrome adjusts scroll position when elements are added at the top of the
// view. We want to have the same behavior as react-native / Safari so we
// reset the scroll position to the last value we got from an event.
const lastScrollOffset = lastScrollOffsetRef.current;
const scrollOffset = getScrollOffset();
if (lastScrollOffset !== scrollOffset) {
scrollToOffset(lastScrollOffset, false);
}

We continuously save the last scroll offset here.

const scrollOffset = getScrollOffset();
lastScrollOffsetRef.current = scrollOffset;

But somehow, after updating the money request, the last scroll offset is 0 and the current scroll offset is the correct scroll offset. That is because, when a view has a display of none, the scroll offset is 0 (scrollTop).

const getScrollOffset = useCallback((): number => {
if (!scrollRef.current) {
return 0;
}
return horizontal ? getScrollableNode(scrollRef.current)?.scrollLeft ?? 0 : getScrollableNode(scrollRef.current)?.scrollTop ?? 0;
}, [horizontal]);

The flow is like this:

  1. Open the description page, report RHP is hidden
  2. Update the description, a system message that the description is added. This triggers the first mutation observer. The last scroll offset contains the prev scroll offset, but the current scroll offset is 0. This calls scrollToOffset to the last scroll offset (the correct scroll offset).
  3. The mutation observer calls prepareForMaintainVisibleContentPosition which updates the last scroll offset to the current scroll offset, that is 0.
  4. The list is displayed, trigger the second mutation observer. At this point, the prev scroll offset is 0 and the current scroll offset is the correct offset. This calls scrollToOffset to the last scroll offset, 0, to the bottom.

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

Ignore the mutation observer if the list is hidden.

One way to check if it's hidden is to check whether the height is 0 or not. A hidden view will have a height (or width) of 0.

const mutationObserver = new MutationObserver(() => {
// This needs to execute after scroll events are dispatched, but
// in the same tick to avoid flickering. rAF provides the right timing.
requestAnimationFrame(() => {
// Chrome adjusts scroll position when elements are added at the top of the
// view. We want to have the same behavior as react-native / Safari so we
// reset the scroll position to the last value we got from an event.
const lastScrollOffset = lastScrollOffsetRef.current;
const scrollOffset = getScrollOffset();
if (lastScrollOffset !== scrollOffset) {
scrollToOffset(lastScrollOffset, false);
}

if (!getScrollableNode(scrollRef.current)?.clientHeight) {
    return;
}

OR

Don't save the scroll offset in prepareForMaintainVisibleContentPosition if the list is still hidden.

const contentView = getContentView();
if (contentView == null) {
return;
}
const scrollOffset = getScrollOffset();
lastScrollOffsetRef.current = scrollOffset;

if (contentView == null || !getScrollableNode(scrollRef.current)?.clientHeight/clientWidth) {

@greg-schroeder
Copy link
Contributor

Proposal review underway

Copy link

melvin-bot bot commented Jul 19, 2024

@greg-schroeder, @alitoshmatov, @aldo-expensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Jul 19, 2024
@greg-schroeder
Copy link
Contributor

bump @alitoshmatov

Copy link

melvin-bot bot commented Aug 6, 2024

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

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

melvin-bot bot commented Aug 6, 2024

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

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

Copy link

melvin-bot bot commented Aug 6, 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:

  • [@alitoshmatov] The PR that introduced the bug has been identified. Link to the PR:
  • [@alitoshmatov] 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:
  • [@alitoshmatov] 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:
  • [@alitoshmatov] Determine if we should create a regression test for this bug.
  • [@alitoshmatov] 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.
  • [@greg-schroeder] 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 Overdue and removed Weekly KSv2 labels Aug 12, 2024
@greg-schroeder
Copy link
Contributor

Processing

@melvin-bot melvin-bot bot removed the Overdue label Aug 13, 2024
@greg-schroeder
Copy link
Contributor

Payment summary:

Contributor: @bernhardoj - $250 - You can make a manual request via ND
C+: @alitoshmatov - $250 - Paid via Upwork

cc @alitoshmatov can you complete the checklist so we can close this out? Thanks!

@greg-schroeder greg-schroeder removed the Awaiting Payment Auto-added when associated PR is deployed to production label Aug 13, 2024
@greg-schroeder greg-schroeder changed the title [HOLD for payment 2024-08-13] [$250] Search - Report always auto scroll down after editing the expense from RHP [C+ Checklist Needs Completion] [$250] Search - Report always auto scroll down after editing the expense from RHP Aug 13, 2024
@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

@melvin-bot melvin-bot bot added the Overdue label Aug 15, 2024
@aldo-expensify
Copy link
Contributor

Friendly bump @alitoshmatov on completing the list

Copy link

melvin-bot bot commented Aug 16, 2024

@greg-schroeder, @bernhardoj, @alitoshmatov, @aldo-expensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@alitoshmatov
Copy link
Contributor

@melvin-bot melvin-bot bot removed the Overdue label Aug 18, 2024
@aldo-expensify aldo-expensify changed the title [C+ Checklist Needs Completion] [$250] Search - Report always auto scroll down after editing the expense from RHP [$250] Search - Report always auto scroll down after editing the expense from RHP Aug 20, 2024
@melvin-bot melvin-bot bot added the Overdue label Aug 20, 2024
@aldo-expensify
Copy link
Contributor

@greg-schroeder was everyone payed? are we ready to close this?

@aldo-expensify aldo-expensify added Weekly KSv2 and removed Daily KSv2 labels Aug 20, 2024
@melvin-bot melvin-bot bot removed the Overdue label Aug 20, 2024
@greg-schroeder
Copy link
Contributor

yup! closing

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. Engineering External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
No open projects
Status: Done
Development

No branches or pull requests

6 participants