-
Notifications
You must be signed in to change notification settings - Fork 283
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
Fixes implicit scroll to top on android when orientation changes #187
Conversation
@@ -360,7 +362,15 @@ class FlashList<T> extends React.PureComponent< | |||
); | |||
} | |||
|
|||
private validateListSize(event: LayoutChangeEvent) { | |||
const { height, width } = event.nativeEvent.layout; | |||
if (Math.floor(height) <= 1 || Math.floor(width) <= 1) { |
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.
We have to give a non zero size and I've used 1. This warning will show up if lists' either dimension <2px. I need floor because onLayout can have slightly higher values in some cases.
I also like the fact that we've moved to a warning instead of an error. I think this is fair because if a list is rendered with such a small size it most like means parent uses flex-start
or something similar. My intent is to only catch this issue thus I want to use smallest value possible.
We cannot skip the warning because bounded size issue happens quite a lot and showing the solution right there helps developers.
Please do review this and merge if everything looks good! |
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.
Note to self and anybody else re: 🎩 - you have turn on auto-rotate in the emulator's settings 😅
I have 🎩 'd this and looks good 👏 ✅
Description
When orientation is changed for the first time on Android the list scrolls to the top. This does not happen on iOS. While debugging I noticed that this issue started to happen when we stopped using RLV's render footer.
RLV's footer is rendered separately from the list items so on the first render which is used to measure the scrollview this footer would give some content to scrollview which was non zero in size. I don't know the reason but if content is of zero height when scrollview mounts then on its size change it raises a scroll event with offset 0px. This looks like an issue in ScrollView and not the list.
To solve this I've to set some min size to the content. More context is present in comments with the changes.
Reviewers’ hat-rack 🎩
Video
Screen.Recording.2022-03-15.at.23.59.58.mov
Checklist