On press is called when context menu being released too quickly
I have the following code structure for the flat list items:
<ContextMenu
previewBackgroundColor={"black"}
actions={[{ title: "Open article" }, { title: "Remove from favourites", destructive: true, systemIcon: 'trash' }]}
onPress={(e) => {....}
}}
>
<TouchableOpacity onPress={() => onPress(item.id)}>
...
</TouchableOpacity>
</ContextMenu>
When I tap on an item and hold it then everything is okay, but when I release it too quickly then the onPress method is called that, in my case, leads to redirecting to another page.
Is there a way to track whether the menu is currently opened, so I can block the redirecting to another screen until it's closed?
Here is the video showcasing the bug:
https://user-images.githubusercontent.com/31933374/179400146-5d819a23-66ef-4481-8274-fbc264a0e224.MP4
I am not having this problem in iOS, but the problem is still there in android.
Hi, can u add timeout for your action?
I'm experiencing the same problem on Android, it's working well on iOS. Does anyone have a workaround?
Edit: Found a workaround, on your TouchableOpacity element, pass an empty function to onLongPress and that will fix it.
Thanks @focux . His solution works, you might be able to intercept the event to stop propagation of the pressabke if it's grabbed by the long press but I have not tried
I am using this library with Expo Router. Somehow my screen isn't navigating to any screen anymore with router.push() on iOS when I opened and closed the ContextMenu before. But this only happens on a physical device. On the simulator its working... Does somebody have the same problem?
Hi! Who still having this having issue and passing empty function to your onLongPress property didn't help you. Try add delayLongPress property to your TouchableOpacity or Pressable element and set it to 250 (default 500)
@focux @DimanVorosh solution seems to work but I hope to see a fix for this in the near future. thanks for the great package also adding delayLongPress={250} seems to do the trick