-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
The calculations for onViewableItemsChanged
are incorrect if Flatlist has ListHeaderComponent
#16612
Labels
Issue: Author Provided Repro
This issue can be reproduced in Snack or an attached project.
Resolution: Locked
This issue was locked by the bot.
Resolution: PR Submitted
A pull request with a fix has been provided.
Comments
shakyShane
added a commit
to shakyShane/react-native
that referenced
this issue
Oct 31, 2017
… in VirtualizedList - fixes facebook#16612
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
stale
bot
added
the
Stale
There has been a lack of activity on this issue and it may be closed soon.
label
Dec 30, 2017
shakyShane
added a commit
to shakyShane/react-native
that referenced
this issue
Jan 2, 2018
shakyShane
added a commit
to shakyShane/react-native
that referenced
this issue
Jan 2, 2018
… in VirtualizedList - fixes facebook#16612
shakyShane
added a commit
to shakyShane/react-native
that referenced
this issue
Jan 2, 2018
shakyShane
added a commit
to shakyShane/react-native
that referenced
this issue
Jan 2, 2018
… in VirtualizedList - fixes facebook#16612
Is it possible to land this? That bug is still there. |
hramos
added
Resolution: PR Submitted
A pull request with a fix has been provided.
🔶Lists
Issue: Author Provided Repro
This issue can be reproduced in Snack or an attached project.
labels
Jun 28, 2018
stale
bot
removed
the
Stale
There has been a lack of activity on this issue and it may be closed soon.
label
Jun 28, 2018
hramos
pushed a commit
that referenced
this issue
Jul 4, 2018
#17415) Summary: … in VirtualizedList - fixes #16612 Issue is detailed in #16612 <!-- Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html Happy contributing! --> I need `onViewableItemsChanged` to account for the length of any ListHeaderComponents I couldn't find any tests that currently cover the use-case of a VirtualizedList + ListComponent + scroll with onViewableItemsChanged, so I have not added any tests - all previous tests pass however. <!-- Help reviewers and the release process by writing your own release notes **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [-{Component}-] [ INTERNAL ] [ ENHANCEMENT ] [ {File} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| [CATEGORY] [TYPE] [LOCATION] - MESSAGE EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> [GENERAL][BUGFIX][VirtualizedList] - account for `ListHeaderComponent` length Closes #17415 Differential Revision: D8683555 Pulled By: hramos fbshipit-source-id: 05df7b79c16e3c07c12468e782f3c4b0bdce7403
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Issue: Author Provided Repro
This issue can be reproduced in Snack or an attached project.
Resolution: Locked
This issue was locked by the bot.
Resolution: PR Submitted
A pull request with a fix has been provided.
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 6.9.4
Yarn: 0.19.1
npm: 3.10.10
Watchman: 4.7.0
Xcode: Xcode 9.0 Build version 9A235
Android Studio: 2.3 AI-162.4069837
Packages: (wanted => installed)
react: 16.0.0-beta.5 => 16.0.0-beta.5
react-native: 0.49.5 => 0.49.5
Target Platform: iOS (10.3) (any though)
Steps to Reproduce
ListHeaderComponent
of any lengthonViewableItemsChanged
to track viewable rows in local stateExpected Behavior
onViewableItemsChanged
fires at the correct time(Write what you thought would happen.)
Actual Behavior
calculations for
onViewableItemsChanged
are always off by the length of the header.(Write what happened. Add screenshots!)
Reproducible Demo
Flatlist Bug with ListHeaderComponent
Flatlist
exposesonViewableItemsChanged
- which can be used to determine which elements are currentlyvisible within a list. This works correctly.
If a
ListHeaderComponent
is also given, the calculations used for determining which items are in viewwill be incorrect - by exactly the height of the header.
in
Libraries/Lists/VirtualizedList.js
,this._headerLength
is initialised as0
and then updated on renderto store the length of the header dynamically, but then this value is not used anywhere else.
Calculations need to account for the 'length' of the Header component
We found the easiest way was to subtract the
this._headerLength
from the offset calculation, such asThe text was updated successfully, but these errors were encountered: