killserver / react-native-screenshot-prevent

MIT License
103 stars 39 forks source link

Breaks React Native Toucables onLongPress event. #16

Closed Farhan7786 closed 1 year ago

Farhan7786 commented 1 year ago

When we enable this screenshot prevent. onLongPress touchable events are not firing.

killserver commented 1 year ago

hello. pls - let's see an example when not working. thx

nsdk1999 commented 1 year ago

I am having the same issue. To reproduce on iOS, I can put a component like this:

<Text onLongPress={() => console.log("Long press")}>Test

If I hold down on this component before enabling, the event fires. If I hold down on this component after RNScreenshotPrevent.enableSecureView(), the event will not fire.

Would be great to have this issue fixed. Works well otherwise, and I have not found a solution that works on iOS other than this.

Farhan7786 commented 1 year ago

I am having the same issue. To reproduce on iOS, I can put a component like this:

<Text onLongPress={() => console.log("Long press")}>Test

If I hold down on this component before enabling, the event fires. If I hold down on this component after RNScreenshotPrevent.enableSecureView(), the event will not fire.

Would be great to have this issue fixed. Works well otherwise, and I have not found a solution that works on iOS other than this.

Just a workaround for this issue is to add a delayLongPress of 300 ms on all the touchables which are imported from react native like touchableopacity and pressable it will work. Also i dont think Tag has a property delayLongPress you have to wrap it with a pressable.

killserver commented 1 year ago

Text or View not have property onPress/onLongPress.. all press event create base on PanGestures or other similar, like: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Pressability/Pressability.js#L455 which detect start, move and end screen interaction.. maybe use special components for detect pressing and error not repeat again?

nsdk1999 commented 1 year ago

I was able to get it working with the workaround of adding delayLongPress. My guess is that the view on iOS is interrupting any presses longer than about 300ms, but it does seem to be a repeatable issue.

killserver commented 1 year ago

in clear project - work fine longressing and delayed small then 300ms. I use usePreventScreenshot() and useDisableSecureView() together. need more information. thx

killserver commented 1 year ago

information not send. pls, reopen issue if problem still exist