-
Notifications
You must be signed in to change notification settings - Fork 3k
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-07-10] [$250] Chat does not scroll to the last message when a new message received #43600
Comments
Triggered auto assignment to @bfitzexpensify ( |
ProposalPlease 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.
when onyx update on report data the 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 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 The code could be: const mvcpAutoscrollToTopThresholdRef = useRef(mvcpAutoscrollToTopThreshold);
mvcpAutoscrollToTopThresholdRef.current = mvcpAutoscrollToTopThreshold;
....
// then in adjustForMaintainVisibleContentPosition:
if (mvcpAutoscrollToTopThresholdRef.current != null && scrollOffset <= mvcpAutoscrollToTopThresholdRef.current) {
scrollToOffset(0, true);
} and we must remove App/src/components/FlatList/index.tsx Line 112 in f838795
Other alternative is (workaround): We could use In here, the code could be: const hasNewestReportAction = useMemo(() => lodashGet(reportActions[0], 'created') === props.report.lastVisibleActionCreated, [reportActions.length]); So when new report action is updated, the |
Job added to Upwork: https://www.upwork.com/jobs/~0178751bd086a2062a |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt ( |
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 |
@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 |
@tsa321 I'm able to reproduce now. Regarding your RCA:
After testing the latest rendered value is 250 but this is still not scrolling. Can you please investigate this more? Screen.Recording.2024-06-19.at.1.08.33.AM.mov |
@s77rt you are logging above this line right? : App/src/components/FlatList/index.tsx Line 104 in f838795
Please add the delta value, macos-web--d.mp4The delta here is important to determine whether there is a change in list content (in this issue: new message from other user). The mvcpAutoscrollToTopThreshold must be latest value when the delta is above 0.5. I have updated my proposal on last paragraph of RCA . |
@tsa321 Screen.Recording.2024-06-19.at.9.25.55.PM.mov |
@s77rt in here: App/src/components/FlatList/index.tsx Lines 148 to 156 in a4a1b20
When So what you say about setupMutationObserver on:
It is not too early, it is because of first value change of When new reportAction merged by onyx, (mvcpAutoscrollToTopThreshold changes from undefined to 250) the So the simplest fix in this issue is to prevent creating new subscriber when mvcpAutoscrollToTopThreshold value changes. App/src/components/FlatList/index.tsx Line 112 in a4a1b20
We remove // at the top
const mvcpAutoscrollToTopThresholdRef = useRef(mvcpAutoscrollToTopThreshold);
mvcpAutoscrollToTopThresholdRef.current = mvcpAutoscrollToTopThreshold;
....
....
// then inside adjustForMaintainVisibleContentPosition:
if (mvcpAutoscrollToTopThresholdRef.current != null && scrollOffset <= mvcpAutoscrollToTopThresholdRef.current) {
scrollToOffset(0, true);
} |
@tsa321 Makes sense! The solution looks good to me 🎀 👀 🎀 C+ reviewed |
Triggered auto assignment to @marcochavezf, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
📣 @s77rt 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @tsa321 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
@s77rt PR is ready... |
Can we retest again in a it to verify this is fixed everywhere based on #44132 (comment) thanks! |
@tsa321 This actually seems broken on |
@s77rt you are right. it is broken in main. I am investigating it |
@s77rt Early investigation: after App/src/components/FlatList/index.tsx Lines 176 to 181 in 27a8d0a
I will further investigate why it is currently behaving that way. Update: When opening a report, the ReportScreen gets mounted, unmounted, mounted, unmounted, and then mounted again, resulting in it being remounted 2-3 times. |
@tsa321 Any idea on which PR broke this? It's seems to be a deploy blocker as this works on staging |
@tsa321 I see, this is related to |
|
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:
|
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:
|
|
Payments complete. Closing this one out. |
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: 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:
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?
Screenshots/Videos
Recording.205.mp4
Screen.Recording.2024-06-11.at.21.37.40.mov
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @bfitzexpensifyThe text was updated successfully, but these errors were encountered: