Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scrollview over bounds of content size (#23427)
Summary: Fix scrollview `offset` out of content size in iOS, Android uses `scrollTo` and `smoothScrollTo` which not have this issue. Fixes like #13594 #22768 #19970 . [iOS] [Fixed] - Fixed scrollView offset out of content size. Pull Request resolved: #23427 Differential Revision: D14162663 Pulled By: cpojer fbshipit-source-id: a95371c8d703b6d5f604af0072f86c01c2018f4a
- Loading branch information
f6516d2
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.
Any chance this behavior can be made optional (with an opt-in/opt-out prop depending upon the default)? In our apps, we use the over scroll ability to move content out of the way of the virtual keyboard. Not sure if we are the exception here but it may impact other projects that were relying on this ability. @zhongwuzw
f6516d2
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.
I think you can use
contentInset
to adjust scroll area?f6516d2
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 you do that then the user can scroll all the way down to it. We only want to permit the over scroll programmatically when the onFocus event is fired from a TextInput on the screen.
f6516d2
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.
I can see a way of doing it with contentInset assuming a new state variable is created in my components and keyboard event listeners are used but I was hoping to not go down that road if possible. I can make an attempt at a new prop to opt out of this behavior and create a PR proposing the change. My native skills are shaky at best but I'll give it a go.
f6516d2
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.
it's better to add a new boolean param (false by default) to scrollTo method than just change it's old behavior
f6516d2
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.
A new Boolean param was added that allows for opting back in to the old behavior
f6516d2
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.
@mysport12 Do you know where the new Boolean param is at, and where it can be set, which allows for opting back in to the old behavior? The app I'm working on is experiencing some unintended side-effects which appear to be caused by this change.
f6516d2
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.
@mysport12 ^ Disregard the above question, I see it in RN 0.59.4: e3ac329 .
f6516d2
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.
@jjhampton To opt back in to the old behavior you can pass a prop to your ScrollView.
scrollToOverflowEnabled={true}
Or set it globally like we do in our apps. In App.js set the defaultProps outside of your component with something like this...
ScrollView.defaultProps = {
...ScrollView.defaultProps,
scrollToOverflowEnabled: true
}
Hope that helps!