-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
bug: passing scrollRef causes element being pinned to top without respecting height of nodes before the scrollview #75
Comments
I thought of the same on the first version. But I ultimately decided not to. The simplest solution to that problem is to add paddingTop to your FlashList. I wanted to reduce the complexity of the constraints code. Had no choice with the FooterComponent since it needs to stick at the bottom. FWIW I believe the "standard" is to use padding on the list and float the header, it's much consistent/performant when you want to animate it together with the list. |
Pretty odd imo. Header is a sibling of TrueSheet. Magically pinning it to 0,0 is kinda weird to me, just because I passed a scrollRef. I'll try it again later, but in my tests I wasn't able to make it work correct with padding. Removing the scrollRef works, not sure about the downsides yet, since in this particular case we do not expand the sheet. |
@hirbod yeah, it needs to be pinned for the sheet to work. It's how IOS's bottom sheet works.... if you remove the For consistency with android, float your header and add |
I tried various solution to the auto height problem and ended up with the layout constraints for IOS. Like adjusting the height of the list when dragging, etc. The constraints code is only the most performant. Thus needing the |
Gotcha, will dig deeper later. |
By the way, speaking of FlashList: adding an example for it would be good, too. Specially since getting the ref is a little bit different. |
I actually didn't know that :D. I'll add it to the docs! Thank you |
FYI, using [500, 'large'] does not work with FlashList, the list does expand but the height is not adjusted. |
Can you try passing the default |
Passing the default ref of FlashList is not working. Passing the wrapped ref of the View behaves almost identical. Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-07-28.at.17.45.57.mp4 |
Yeah.. it has something to do with the FlastList's internal. It may have another "container" that's preventing the height constraint to work. A dirty fix would be to wrap the list on a view with static height :/ const dimensions = useWindowDimensions() <View style={{ height: dimensions.height - insets.top }}>
<FlashList />
</View> |
I have a feeling that this will get better when new arch is already supported. My guess is that FlashList is doing some calculation on the parent but it can't determine the adjusted height since it's resized natively. |
Using |
Hi @hirbod, could you give me some hints on how you created the "Add comment" section? I am making a similar "Comments" screen and I have tried putting it into the footer but then I have some problems when trying to use KeyboardAvoidingView. |
Assume the following structure:
All good so far. But once I pass the scrollRef (with FlashList, unlike FlatList, you need to pass the scrollableNode like so):
It works fine. The main problem I have is that (at least on iOS; I haven't tested Android yet), there is a utility function called
pinTo
, which now pins the whole view behindMyHeaderComponent
, thus not taking the element's height into account.I've experimented with
TrueSheetView
and tested adding offsets like so:So this works. I think there are multiple ways to solve this problem:
You may ask why I don't use HeaderComponent by FlashList? Well, because it does not keep the header fixed.
My example above is just a quick "test", not a fix. The offset needs to be reflected in all calculations etc, similar to the footer.
The text was updated successfully, but these errors were encountered: