react-native-screens: Scrollview not working properly in v4 formSheet
Description
Not sure if I should be posting this here or in react-navigation, nor if its too early since things are still in beta!
But I was requested to post this via: https://github.com/react-navigation/react-navigation/pull/12196#issuecomment-2425929004
Scrolling inside a scrollview inside a formSheet modal does not seem to work on new rc/beta react-navigation & react-native-screens.
See video demo here:
https://github.com/user-attachments/assets/ee93e076-71f1-4c13-b3c6-c1d8a0deeb8e
Steps to reproduce
- Open a modal type formSheet on native stack with ScrollView in it
- Try to scroll, bounces back to top
- If you pull up on the modal towards status bar & then try to scroll, it works
Snack or a link to a repository
https://github.com/peterjskaltsis/rn-screens-repro
Screens version
4.0.0-beta.11
React Native version
0.74.5
Platforms
iOS
JavaScript runtime
Hermes
Workflow
Expo managed workflow
Architecture
Paper (Old Architecture)
Build type
Debug mode
Device
iOS simulator
Device model
iPhone 16 Pro
Acknowledgements
Yes
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 7
- Comments: 35 (8 by maintainers)
Any update? I am using
formSheetand if I nest aScrollViewinside the screen there is a scrolling conflict on Android. If I keep pressing the scroll I can go up and down, but if I scroll down, leave, and try to go back up on the list, it actually closes the formSheet instead of correctly scrolling to the top of the list AND THEN closing the formSheet. This behaviour is correct on iOS.https://github.com/user-attachments/assets/9cf93278-0fee-46ae-93d3-915e8ff973d3
Hey, sorry this isn’t fixed yet. There are plenty of tickets on the radar just haven’t had opportunity to dig into this one yet. I’ll try to handle this one in upcoming 1-2 weeks. Thanks for the remainder.
Hey!
Thank you!
Problem not resolved. Any solution about worked ScrollView inside ‘formSheet’ screen? Simple temporary solution for me it replace
formSheettomodal. For iOS it looks similar (in my case it’s ok)https://github.com/user-attachments/assets/0bbec3cc-a707-4a1c-8c30-ef908a9a9458
I just wanted to update here, that the issue turned out to be more complex than I’ve thought initially & I’ve moved to doing other things, because most likely we’ll need ability of synchronous React Native’s layout on UI thread do resolve this issue, which is not available on Paper (and not yet sure how to do it on Fabric). Will be back to handling this after we release v4 (should be days from now).
Okay! I confirm the issue. If
sheetAllowedDetentsis not set or if thesheetAllowedDetentsis set to a single value - the bug occurs.Thanks!
I’ll look into this later today!
@kkafar Thanks for taking a look and digging in. Is there any updates on the matter?
You can use ScrollView imported from
react-native-gesture-handlerinstead of importing fromreact-native.import { ScrollView } from "react-native-gesture-handler";Then, you can scroll up without closing a screen on Android.
Any updates on this? I see your PR from October @kkafar, any luck with that? For context, in my case (Expo 52, Fabric) ScrollView inside
modalscreens (notformSheet) is behaving weirdly and I think it may be related with this issue.The ScrollView’s height seems to be miscalculated, and “jumps” on touch events. Sometimes it shows correctly when opening a modal, and some other times it’s just wrong (same modal, same screen). Seems a bit random.
Because of the height variation, a component I have as a “footer” of these screens (sibling to the scrollview, with margin top auto) is sometimes pushed outside of the modal screen, without the possibility to scroll to it.
I’ve managed to make things work again by just placing my footer component inside the scrollview itself, with a fixed margin top, which makes it look kinda bad, but at least it is functional.
This started happening after I upgraded from Expo 51 to 52 (which included the react-navigation upgrade to v7, and screens to v4.1.0) and enabled new arch.
I’m also have some trouble with v4
https://github.com/user-attachments/assets/9fd17eee-9b3f-4107-989b-297f254d8222
Bumping on this again… as far as I can tell
flex: 1doesn’t work on any components within aformSheetpresentation. I’m trying to do something like Instagram’s comment formSheet where there are two detents, one half, one full, and the content expands to fit the size of the sheet.Yeah… I was testing on Fabric. On paper I do not have the problem at all, as I believe view flattening does not exist on Paper & iOS combination .