-
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
FlatList with sticky ListHeaderComponent, stickyHeaderIndices, onViewableItemsChanged gives incorrect viewableItems #31109
Comments
If you have such a need about sticky header, I think you can use SectionList to render it? Put the data of the flatList into the function App() {
const [list, setList] = useState([])
const [sectionList, setSectionList] = useState([])
useEffect(() => {
setList(new Array(20).fill(0))
}, [])
useEffect(() => {
setSectionList([
{
title: 'Sticky Tab',
data: list,
},
])
}, [list])
return (
<SectionList
stickySectionHeadersEnabled
sections={sectionList}
keyExtractor={(item, index) => item + index}
renderItem={({ item }) => <ItemCompoment/>}
renderSectionHeader={({ section: { title } }) => <StickyCompoment />}
/>
)
} |
@452MJ I appreciate the suggestion. I just tried it and it behaves the same as the <>
<ListHeader/>
<FlatList
viewabilityConfigCallbackPairs={viewabilityConfigCallbackPairs.current}
/>
</> |
If you don't use ZIndex, components are layered. So the ListHeader will naturally be underneath the FlatList. It just looks weird in code |
Is it just off by the one that's underneath the header? (like if you scroll down more is it including both 1 and 2?) Or are there more offscreen items being included as "viewable"? There's a question about how many are realized versus how many are visible. @NickGerleman hadn't you done some digging into what it'd look like to have this more customizable? |
If i scroll enough so that items 1 and 2 are behind the |
Applicable to FlatList with ListHeaderComponent Funny thing is that the fix was there. But currently — as of 0.64 — it is back to square one. This feature is really important but such omissions render it useless when it comes to FlatLists with headers. One thing to notice — it won't take into account whatever margin / padding you may have set via |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
This issue was closed because it has been stalled for 7 days with no activity. |
Description
When we use
<FlatList />
withstickyHeaderIndices
,viewabilityConfigCallbackPairs
, andListHeaderComponent
together and when we scroll the list andonViewableItemsChanged
is called, theviewableItems
includes the items that are behind (not viewable) the sticky list header.React Native version:
"react-native": "0.63.4"
Steps To Reproduce
viewableItems
Expected Results
I expect in
viewableItems
that the item with id 1 is not present and that the item with id 2 is the first in the list.Snack, code example, screenshot, or link to a repository:
https://snack.expo.io/@tantommy/intelligent-churros
Related Issues:
stickyHeaderIndices
fix: account forListHeaderComponent
length when calculating offset… #17415onViewableItemsChanged
are incorrect if Flatlist has ListHeaderComponent #16612The text was updated successfully, but these errors were encountered: