onPress not working
See original GitHub issueDescribe the bug
I am not able to use onPress
inside my SwipeableItem
overlays. I started with the demo list from the README and added a onPress
in addition to the onLongPress
, but it’s never called.
Steps to reproduce the behavior:
Here’s a demo project. Long pressing to reorder works. But when you do a regular press it should change all the item texts to “An item was pressed”. Instead nothing happens.
Platform & Dependencies None in the demo project.
Platform (iOS/Android):
React Native or Expo version: 0.61.5
react-native-reanimated
version: 1.7.0
react-native-gesture-handler
version: 1.5.6
Additional context
This is important functionality since you might want to show a new list when tapping, edit the item, etc. So primary action would be through tapping and secondary action(s) through swipes. My first idea for a workaround is to make a new component that extends TouchableOpacity or TouchableWithoutFeedback and uses onPressIn and onPressOut with some timers (although I would have guessed that’s exactly how TouchableWithoutFeedback is implemented). Or maybe to just act on onPressOut (if onDragBegin was never called). Have to investigate which events are called and when.
Do you have any idea why it’s not working? Seems like it might be nice to document this if a workaround is possible. And if a workaround is possible then it would make sense to me to integrate it into the library and add onPress and onLongPress directly to the SwipeableItem.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Removed TapGestureHandler in react-native-draggable-flatlist 2.3.0, please upgrade let me know if the onPress issue is fixed.
OK, sorry about the delay and thanks for letting me know about the new version!
onPressIn
,onPress
, andonLongPress
work as expected, whereasonPressOut
is never called. This is fine for me sinceonPress
is what I really need.