react-native-gesture-handler
react-native-gesture-handler copied to clipboard
DrawerLayout containing FlatList stays open when using openDrawer
Description
We have a main drawer that we open with a button. The home screen of our app has a big FlatList with content. After opening the DrawerLayout twice using openDrawer()
, if you scroll down, the drawer gets stuck open. There is no transition when it opens the final time and logging suggests that it thinks it's closed.
I have a full reproduction here: https://github.com/statico/rngh-mobile-bug
Direct link to code: https://github.com/statico/rngh-mobile-bug/blob/main/app/index.jsx
https://github.com/software-mansion/react-native-gesture-handler/assets/137158/bf7db0ac-e031-457f-82c7-18adb3baefda
"dependencies": {
"expo": "^48.0.19",
"expo-application": "~5.1.1",
"expo-constants": "~14.2.1",
"expo-dev-client": "~2.2.1",
"expo-linking": "~4.0.1",
"expo-router": "^1.0.0",
"expo-status-bar": "~1.4.4",
"metro": "^0.76.6",
"metro-resolver": "^0.76.6",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.8",
"react-native-gesture-handler": "~2.9.0",
"react-native-ios": "^1.1.0",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "~3.20.0",
"react-native-web": "~0.18.10"
},
Steps to reproduce
- Check out the project https://github.com/statico/rngh-mobile-bug
-
yarn install
and runeas build --profile simulator --platform ios
to build a development build, or try grabbing it from https://expo.dev/accounts/statico/projects/rngh-drawer-bug/builds, or maybeeas build:run -p ios
just works? I'm not sure. - Tap the blue "Open Drawer" button
- Tap the gray space on the right to close the drawer
- Repeat steps 3-4 once or twice
- Scroll the red FlatList items
- Enjoy a stuck drawer
Snack or a link to a repository
https://github.com/statico/rngh-mobile-bug
Gesture Handler version
2.9.0
React Native version
0.71.8
Platforms
iOS
JavaScript runtime
Hermes
Workflow
Expo managed workflow
Architecture
None
Build type
Release mode
Device
Real device
Device model
All iPhones are affected
Acknowledgements
Yes
We see the same behavior when upgrading from 2.9.0 to 2.10.0 (and above).
Edit: my mistake, our issue is similar, not identical though. Happens with 2.10.0 above only, not below (you mention testing with 2.9.0). We have:
- Call
openDrawer()
from button - Close by clicking negative space
- Call
openDrawer()
from button --> drawer can no longer be closed by clicking on negative space
This happens 100% of the time on web and sometimes on android / iOS. For android / iOS it seems to happen when you spam click the interface and it's trying to animate something else when doing a drawer close. Behavior similar to https://github.com/software-mansion/react-native-gesture-handler/issues/2208#issuecomment-1381293375
We have no FlatList
in the root view but do have a FlatList
in the drawer itself. The list does not need to be scrolled to cause this issue.
I upgraded to [email protected]
and built a new build, and this issue still occurs.
If anyone has any workarounds or possible fixes, I would be happy to try them!
This actually happens in the example too:
https://github.com/software-mansion/react-native-gesture-handler/assets/137158/d812513b-86d4-4775-8e09-077df1a8def3
BetterHorizonatalDrawer
in the examples works fine. Copying BetterHorizonatalDrawer.tsx
into our project and using that instead of the default DrawerLayout
fixes this problem for now.
This problem has nothing to do with FlatList. I have this problem even if I don’t have FlatList.
https://reactnavigation.org/docs/drawer-layout/ I used this now, it works fine.
Experiencing this as well on react-native-gesture-handler
2.15.0 and React Native 0.70