-
Notifications
You must be signed in to change notification settings - Fork 24.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
tapping on iOS status bar should scroll inverted ScrollViews to their top #27574
tapping on iOS status bar should scroll inverted ScrollViews to their top #27574
Conversation
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.
Approved, with some minor nits on code style.
@@ -829,6 +829,10 @@ - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView | |||
return NO; | |||
} | |||
} | |||
if(self.inverted) { |
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.
if(self.inverted) { | |
if (self.inverted) { |
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.
@hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @emilioicai in 7a4753d. When will my fix make it into a release? | Upcoming Releases |
… top (facebook#27574) Summary: React Native ScrollViews are flipped upside down when the prop inverted is set to true. This is the root of a bug: tapping on the status bar in iOS should scroll the Flatlist up to the top but currently it does to the bottom. The solution proposed is to detect natively if the ScrollView is inverted, on such case, prevent it from scrolling it to the beginning of the ScrollView (as a non-inverted ScrollView would do) and force a scroll to the end of it. I've been careful enough not to force the scroll if the user explicitly selected not to do it or if it's happening in a nested ScrollView, as it is the default behaviour in iOS. Fixes facebook#21126 ## Changelog [iOS] [Fixed] - Inverted ScrollViews scroll to their bottom when the status bar is pressed Pull Request resolved: facebook#27574 Test Plan: - on iOS, add a ScrollView and put enough content to overflow the screen size so it can be scrolled - add the prop `inverted={true}` to the ScrollView - go to the screen the Scrollview is in and press the status bar - it should scroll to top (previously it scrolled to the bottom) ![v](https://user-images.githubusercontent.com/807710/71188640-a0ac6680-2281-11ea-91a7-d1e46aba8b14.gif) Differential Revision: D19185270 Pulled By: hramos fbshipit-source-id: 5445093ff38f4ba4082f1d883d8ed087e9565eaf
@emilioicai sorry for commenting an "old" ticket, but Expo SDK just released with RN 0.62.2 and that fix is included there so its the first time I can test it. Your change works fine so far, the direction works, but only when I scroll "up" at least 1px. If my chat scroll position is "0" a tap on the statusbar won't do anything for me now. If I just scroll up a bit, scroll to top (or here: to bottom since its inverted) works. |
Here is a video (listen to audio please) |
@hirbod were you ever able to find a solution to this issue? I am also experiencing the same thing in RN 0.63.2 |
@PAJoeInc no - unfortunately not, since nobody responded to my message here. |
I think I will have to write a new ticket (which will prob. take a year or two before it gets resolved :D) |
very annoying. i want the old behaviour as how discord handles it. |
Summary
React Native ScrollViews are flipped upside down when the prop inverted is set to true. This is the root of a bug: tapping on the status bar in iOS should scroll the Flatlist up to the top but currently it does to the bottom.
The solution proposed is to detect natively if the ScrollView is inverted, on such case, prevent it from scrolling it to the beginning of the ScrollView (as a non-inverted ScrollView would do) and force a scroll to the end of it.
I've been careful enough not to force the scroll if the user explicitly selected not to do it or if it's happening in a nested ScrollView, as it is the default behaviour in iOS.
Fixes #21126
Changelog
[iOS] [Fixed] - Inverted ScrollViews scroll to their bottom when the status bar is pressed
Test Plan
inverted={true}
to the ScrollView