-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Better Expense Reports] Fix FlatList two-way scroll locally #61065
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
[Better Expense Reports] Fix FlatList two-way scroll locally #61065
Conversation
|
@DylanDylann 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] |
…-fork into Guccio163/twoWayScrollLocal
@DylanDylann are you on track to review this? |
I will try to complete my review today. Or at least, I will complete it on Monday for sure |
@Guccio163 Did you test this change on the Hybrid App? It caused the crash App because addEventListener is only available on web platform ![]() |
You're right, I didn't - I'll try to comment on Monday; Since
Since we can't really push the patch upstream (it's not really a bug) and FlatList doesn't support a |
…-fork into Guccio163/twoWayScrollLocal
Finally, I solved it platform agnostic, just checking whether |
I tested and noticed that the bug isn't fixed completely Screen.Recording.2025-05-06.at.16.57.19.mov |
@@ -537,6 +537,26 @@ function MoneyRequestReportPreviewContent({ | |||
), | |||
}; | |||
|
|||
useEffect(() => { | |||
const node = carouselRef.current?.getScrollableNode?.() as HTMLElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const node = carouselRef.current?.getScrollableNode?.() as HTMLElement; | |
const node = carouselRef.current?.getScrollableNode?.() as HTMLElement; | |
if (!(node instanceof HTMLElement)) { | |
return; | |
} |
Right, because of mouse/wheel events' characteristics this is most of what we can do with a local change like that without big interference into making wrappers, editing ReportActions list etc. The one idea still available is implementing FlatList in |
@mountiny @Guccio163 I think we should keep the patch file to solve this bug completely with a smooth transition. Wdyt? |
Theoretically, the easiest and simplest solution would be to implement an algorithm like "only deltaX difference when scrolling Carousel, only deltaY when scrolling whole list", but there is no way to deterministically detect that on web - there are no wheelStart/wheelEnd events, just a plain 'wheelEvent' and/or 'mouseMove'. The pan.movThe way to go in our scenario is stating constant rules for event handling, just like it is now done in patch and how I aim to finish it here - with a constant eventListener. The problem is that a single swap can generate many wheelEvents and they vary in parameters - that sometimes leads to a situation where among many horizontal wheels, occur single micro events with very small deltaY but even smaller deltaX and that's why it moves vertically a little. Interesting possible solution in using Timeout (f.ex. if user doesn't wheel for longer than 0.2 seconds then assume that he stopped scrolling) and boolean conditional stating whether we currently block vertical or horizontal events; It isn't perfect but should do the job. BTW: By twitching Not an ideal position - I'd probably stay with the current patch or eventListener from this PR, but I'm curious WDYT @mountiny @DylanDylann ? |
…-fork into Guccio163/twoWayScrollLocal
Thanks for the investigation, i agree that if the parch solution is the best for now, lets keep it and focus on other things. We could re-visit this later if we still see some issues with the behaviour and would like to clear the patch |
Agree 👍 |
Works for me, summary is gathered here for the next attempt 👍 |
I think we can close this PR |
Closing! |
Explanation of Change
PR ensures that web implementation of inverted FlatList scrolls in only one direction at a time by comparing X and Y deltas, then choosing the direction with the bigger delta. A follow-up as per this comment to find a fix locally, not to maintain the patch forever - it isn't a bug to be fixed upstream.
Fixed Issues
$ #60276 (comment)
PROPOSAL:
Tests
Offline tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov