fix: Android - Report - User is auto scrolled up after returning from second added receipt#84498
Conversation
|
@ahmedGaber93 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00184668d2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 36b7b43ae0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx
Outdated
Show resolved
Hide resolved
JmillsExpensify
left a comment
There was a problem hiding this comment.
LGTM though merge conflicts
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp20260331192626639.mp420260331192229672.mp4Android: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
@TaduJR Are you able to reproduce the issue on the latest main? I am unable Untitled.mp4 |
Yes @ahmedGaber93 Still able to repo on latest main as of now. Android-Native.mp4 |
|
|
… second added receipt
dd14b13 to
c7d39c7
Compare
Please ignore this. |
|
@TaduJR I’m able to reproduce it now, but I need to manually scroll down and then back up first. Your solution should work, but can we prevent it from scrolling up instead of forcing it to scroll down? It seems to behave correctly when scrolling manually, the issue only occurs after calling |
…ent stale restoration
Sure, just pushed with this approach. |
…-Report-User-is-auto-scrolled-up-after-returning-from-second-added-receipt
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @puneetlath has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/puneetlath in version: 9.3.52-0 🚀
Bundle Size Analysis (Sentry): |
|
I reviewed the changes in this PR. The fix modifies No help site changes are required. This is an internal scroll-tracking bug fix with no impact on user-facing features, settings, workflows, or terminology documented in |
Explanation of Change
That description is for the old fix (
useRestoreScrollOnFocus). Your current fix is different it's theonScrollsync inindex.android.tsx. The PR description needs to match the actual change. Here's an updated version:Problem:
When the user is viewing a transaction thread (the expense detail page with the receipt), adds an attachment via the plus button, opens the just-added attachment, and presses back, the native
FlatListrestores a stale cached scroll position, jumping the user to a position further up in the list instead of staying at the bottom.Root cause:
On Android,
CustomFlatListsaves the scroll offset inlastScrollOffsetRefto restore it when the screen is unfrozen (viauseFocusEffect). However, this ref was only updated ononMomentumScrollEnd— which only fires after user-initiated fling gestures. Programmatic scrolls (likescrollToBottom()fromscrollToBottomForCurrentUserAction) never triggeronMomentumScrollEnd, solastScrollOffsetRefretains a stale high offset from the user's earlier scroll. When the screen regains focus,onScreenFocusrestores this stale offset, scrolling the user up.This was confirmed through extensive instrumentation: the
onScreenFocuslog showedRESTORING offset: 865immediately after returning, even thoughscrollOffsetRef.currentwas0(bottom). The bug is Android-only because iOS uses nativemaintainVisibleContentPositioninstead of manual save/restore.Solution:
Intercept
onScrollinCustomFlatList(Android) to keeplastScrollOffsetRefin sync with all scroll events both user-initiated and programmatic. This ensuresonScreenFocusalways restores the correct offset.Fixed Issues
$ #84362
PROPOSAL:
Tests
Tests
Prerequisite: Account has at least one workspace.
Test Case 1:
Test Case 2:
Offline tests
Same as tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android-Native.mp4
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari