react-native-swipeable-item icon indicating copy to clipboard operation
react-native-swipeable-item copied to clipboard

Can't press buttons during the swiping

Open sviatoslav-lebediev opened this issue 2 years ago • 5 comments

Describe the bug It's not possible to press elements during the swiping. We have two buttons on the right side. When I swipe to the left, I can press them after the swiping process stops (+ need to wait for ~ 100 ms after a stop).

Steps to reproduce the behavior: Swipe and try to press any elements that have onPress handlers. Handlers will not be triggered.

Platform & Dependencies Please list any applicable dependencies in addition to those below (react-navigation etc).

Platform (iOS): React Native: 0.67.4 react-native-reanimated version: 2.2.4 react-native-gesture-handler version: 2.1.0

Here is an example https://snack.expo.dev/@moro/swipeable-draggable-list If you swipe and press delete it will not trigger the action, you need to wait until the swiping stops.

sviatoslav-lebediev avatar May 12 '22 14:05 sviatoslav-lebediev

We've found the cause of this:

  • pointer events are disabled based on which open direction is set [code]
  • this is currently set onAnimationEnd [code]
  • this results in pointer events being blocked until the animation is fully done, even if item is visible

We've validated this by calling onComplete here which results in onAnimationEnd being called and the openDirection state being updated. This makes the underlay pressable.

Happy to open a PR to fix this, but I'm not sure of the best way to do this. Would it be sufficient to update the open direction via a set state call run on JS thread here (same location as onComplete call above)? Not sure if there will be other downstream impact from this.

jmif avatar Jul 15 '22 19:07 jmif

@jmif your solution and PR would be very welcome.

edit: I've tested your proposed solution and it seems to work. The PR is here https://github.com/computerjazz/react-native-swipeable-item/pull/55.

vbylen avatar Aug 13 '22 05:08 vbylen

Thanks @vbylen!

jmif avatar Aug 15 '22 09:08 jmif

please try https://github.com/computerjazz/react-native-swipeable-item/releases/tag/v2.0.8 and let me know if it fixes the issue.

computerjazz avatar Aug 20 '22 21:08 computerjazz

@computerjazz it's working great, thank you!

vbylen avatar Aug 20 '22 23:08 vbylen