Invert iOS scroll-to-top gesture scroll so it also scrolls to the top when using inverted ScrollViews #54831
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
When using
invertedin a component that uses UIKit'sScrollViewunder the hood and tapping the status bar (scroll-to-top gesture), instead of scrolling to the top, we end up going to the bottom because of the -1 transform invert.I think this fix has 1 (likely inevitable) bug that seems to be unfixable without upstream changes on iOS or a hacky workaround. It won't trigger the scroll when at
y = 0(the absolute bottom), it thinks we are at the top of the list because of the -1 transform, thus it doesn't scroll:You can see this behavior here (this is from my branch), notice that the gesture only works when I scroll up a bit:
invert-scroll.mov
I'm opening this PR because of an issue in another repo (Expensify) I'm working on, there, I came to the conclusion that we had two options for working around this:
You can see more details here.
I think there might be another way of working around this which would be using an invisible
ScrollViewto catch the gesture, but this would likely be even worse than the other 2 options.I also remember reading that this has been attempted before in a PR on the old arch and it had the same exact bug. I'll try to link it here if I find it later.
I think I could implement a prop that activates the 1-pixel workaround described above, and another that disables this PR entirely (scrolls to the bottom, like it's being done now) so that developers can choose.
Obviously, everything I described above is not ideal, and simply a workaround, I would love to hear if anyone has any other ideas on how to tackle this.
Changelog:
[iOS] [CHANGED] - Fix scroll-to-top gesture on inverted lists
Test Plan:
This is a simple change but there is 1 known bug that I'd like to address before writing this section (more details above).