You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2024-07-10] [$250] Chat does not scroll to the last message when a new message received #43600
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
Version Number: 1.4.82-0 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 Expensify/Expensify Issue URL: Issue reported by:@youssef-lr Slack conversation:
Action Performed:
Go to a report with lots of messages
Send a message to user B
Expected Result:
For user B the chat scrolls to the last message received
Actual Result:
Does not scroll
Workaround:
unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Please re-state the problem that we are trying to solve in this issue.
Chat does not scroll to the last message when a new message received
What is the root cause of that problem?
When user receive new message, the pushJSON data contains onyx update for report and the new reportAction.
The report onyx data will update lastVisibleAcitonCreated and reportAction will add new latest reportAction.
In here:
when onyx update on report data the hasNewestReportAction will be false because the reportActions isn't updated yet, then the onyx will update reportActions which will make hasNewestReportAction to be true. So there is toggling false then true after the complete update of data from push event.
The hasNewestReportAction will affect enableAutoscrollToTopThreshold value, which is the scrolling logic depends on.
when the pushData update completed, the mvcpAutoscrollToTopThreshold value used in here isn't the latest mvcpAutoscrollToTopThreshold. the value is still undefined because of the update from report onyx data and hasn't been updated after reportAction onyx merged. So when the delta value is higher 0.5 / new message inserted in list, the value of mvcpAutoscrollToTopThreshold hasn't been updated.
Since the `adjustForMaintainVisibleContentPosition` is used in subscriber of `MutationObserver`, we need the updated value right at when message is inserted into the list. So we need the latest value and using ref here can solve the issue.
If we are using useCallback that depend on the `mvcpAutoscrollToTopThreshold` the new subscriber will be created and will disturb detection in `mutationObserver` when observing the list content difference.
Sometimes I noticed, when new subscriber based on new callback produced by useCallback, the list is already changes and delta difference is still 0.
So we must remove the dependency of `mvcpAutoscrollToTopThreshold` in `adjustForMaintainVisibleContentPosition` and use ref of mvcpAutoscrollToTopThreshold.
What changes do you think we should make in order to solve the problem?
We must remove the dependency of mvcpAutoscrollToTopThreshold in adjustForMaintainVisibleContentPosition and we could use ref of mvcpAutoscrollToTopThreshold at the top of the function component and immediately update it when new mvcpAutoscrollToTopThreshold available, then use it inside adjustForMaintainVisibleContentPosition
The code could be:
constmvcpAutoscrollToTopThresholdRef=useRef(mvcpAutoscrollToTopThreshold);mvcpAutoscrollToTopThresholdRef.current=mvcpAutoscrollToTopThreshold;
....// then in adjustForMaintainVisibleContentPosition:if(mvcpAutoscrollToTopThresholdRef.current!=null&&scrollOffset<=mvcpAutoscrollToTopThresholdRef.current){scrollToOffset(0,true);}
and we must remove mvcpAutoscrollToTopThreshold in :
changed the title [-]Chat does not scroll to the last message when a new message received[/-][+][$250] Chat does not scroll to the last message when a new message received[/+]on Jun 17, 2024
@s77rt Currently, I am not with my computer, but I am guessing that the PR causing the issue is #42592
For the comment linking should also check on #44412
changed the title [-][$250] Chat does not scroll to the last message when a new message received[/-][+][HOLD for payment 2024-07-10] [$250] Chat does not scroll to the last message when a new message received[/+]on Jul 3, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.3-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
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:
[@s77rt] The PR that introduced the bug has been identified. Link to the PR:
[@s77rt] 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:
[@s77rt] 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:
[@s77rt] Determine if we should create a regression test for this bug.
[@s77rt] 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.
[@bfitzexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
A discussion in #expensify-bugs has been started: Not needed. Unique bug
Determine if we should create a regression test for this bug: I don't think this requires a test, it could cause false positives as the auto scroll is supposed to happen only if the scroll position is below a certain threshold
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
Activity
melvin-bot commentedon Jun 12, 2024
Triggered auto assignment to @bfitzexpensify (
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.tsa321 commentedon Jun 16, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Chat does not scroll to the last message when a new message received
What is the root cause of that problem?
When user receive new message, the pushJSON data contains onyx update for report and the new reportAction.
The report onyx data will update
lastVisibleAcitonCreatedand reportAction will add new latest reportAction.In here:
App/src/pages/home/report/ReportActionsView.js
Line 215 in a5d0c4d
when onyx update on report data the
hasNewestReportActionwill be false because the reportActions isn't updated yet, then the onyx will update reportActions which will makehasNewestReportActionto be true. So there is toggling false then true after the complete update of data from push event.The hasNewestReportAction will affect enableAutoscrollToTopThreshold value, which is the scrolling logic depends on.
In here:
App/src/components/FlatList/MVCPFlatList.js
Lines 101 to 102 in a5d0c4d
when the pushData update completed, the
mvcpAutoscrollToTopThresholdvalue used in here isn't the latest mvcpAutoscrollToTopThreshold. the value is stillundefinedbecause of the update fromreportonyx data and hasn't been updated after reportAction onyx merged. So when the delta value is higher 0.5 / new message inserted in list, the value of mvcpAutoscrollToTopThreshold hasn't been updated.Since the `adjustForMaintainVisibleContentPosition` is used in subscriber of `MutationObserver`, we need the updated value right at when message is inserted into the list. So we need the latest value and using ref here can solve the issue. If we are using useCallback that depend on the `mvcpAutoscrollToTopThreshold` the new subscriber will be created and will disturb detection in `mutationObserver` when observing the list content difference. Sometimes I noticed, when new subscriber based on new callback produced by useCallback, the list is already changes and delta difference is still 0. So we must remove the dependency of `mvcpAutoscrollToTopThreshold` in `adjustForMaintainVisibleContentPosition` and use ref of mvcpAutoscrollToTopThreshold.
What changes do you think we should make in order to solve the problem?
We must remove the dependency of
mvcpAutoscrollToTopThresholdinadjustForMaintainVisibleContentPositionand we could use ref ofmvcpAutoscrollToTopThresholdat the top of the function component and immediately update it when new mvcpAutoscrollToTopThreshold available, then use it insideadjustForMaintainVisibleContentPositionThe code could be:
and we must remove
mvcpAutoscrollToTopThresholdin :App/src/components/FlatList/index.tsx
Line 112 in f838795
Other alternative is (workaround):
We could use
useMemoto avoid unnecessary value changes onhasNewestReportActionwhen the onyx pushJSON data isn't fully merged yet.In here, the code could be:
So when new report action is updated, the
shouldEnableAutoScrollthat depend onhasNewestReportActionwill keep on true and the List will scroll.[-]Chat does not scroll to the last message when a new message received[/-][+][$250] Chat does not scroll to the last message when a new message received[/+]melvin-bot commentedon Jun 17, 2024
Job added to Upwork: https://www.upwork.com/jobs/~0178751bd086a2062a
melvin-bot commentedon Jun 17, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt (
External)s77rt commentedon Jun 17, 2024
I'm not able to reproduce the bug. @tsa321 Is this still reproducible for you?
Screen.Recording.2024-06-17.at.11.50.57.PM.mov
tsa321 commentedon Jun 17, 2024
@s77rt yes, I can still reprdouce it. You must scroll up to 1 or 2 messages above before receiving new message.
macos-web-d.mp4
23 remaining items
tsa321 commentedon Jun 28, 2024
@s77rt Currently, I am not with my computer, but I am guessing that the PR causing the issue is #42592
For the comment linking should also check on #44412
s77rt commentedon Jun 29, 2024
@tsa321 I see, this is related to
React.StrictModewhich makes the bug dev only. This is a regression from that PR then.[-][$250] Chat does not scroll to the last message when a new message received[/-][+][HOLD for payment 2024-07-10] [$250] Chat does not scroll to the last message when a new message received[/+]melvin-bot commentedon Jul 3, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jul 3, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.3-7 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-07-10. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Jul 3, 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:
s77rt commentedon Jul 7, 2024
bfitzexpensify commentedon Jul 10, 2024
Payments complete. Closing this one out.