react-native-gesture-handler
react-native-gesture-handler copied to clipboard
Cancel failed buttons in reset
Description
This PR is an attempt at fixing bug reported in https://github.com/software-mansion/react-native-gesture-handler/issues/2160.
Essentially when having a button with shouldCancelWhenOutside={true} in a ScrollView and scrolling quickly, especially when at the bottom where the scrollview exhibit rubber band effect, all buttons becomes unresponsive. This is because touchResponder is never freed after it goes into FAILED state, which typically otherwise happens when ACTION_UP is emitted – something that never happens.
I'm not sure of the ideal solution, but I'd figured I share my half-baked workaround to emit CANCEL in onReset if the button is stuck in FAILED. Curious to hear suggestions on how to improve this.
Test plan
Hey, thank you for the PR! Could you please provide a repro where #2160 still occurs? It seems like it should've been fixed by #2187, and I'm not aware of any regressions of that bug.
I tried reproducing this issue with RectButton with shouldCancelWhenOutside={true} in a ScrollView using the steps you provided in this PR, but the issue did not occur despite my best attempts.
Hi I made a minimal reproduction here: https://snack.expo.dev/@oblador/gesture-handler-list-reproduction
Note that this is Android only, see a video of the reproduction where you can notice that before I scroll the first list item responds with a highlight, but afterwards none do:
https://github.com/user-attachments/assets/345f7d82-269f-4066-add4-09cd1b865b55
For what it's worth, I've managed to get into this state even without shouldCancelWhenOutside={true}, but it's just much easier/frequent in this mode. Basically it seems to apply to any case where the handler enter failed state. It's also possible to "resurrect" the app if you know which button caused it to die by scrolling slowly on that specific button, which is in line with above explanation because then ACTION_UP is emitted.
I also rendomly experience when in a ScrollView there are two buttons and the second one ( (it's FAB) overlaps the first one.
Sometimes pressing a FAB buttons also triggers the underlying button (the ripple animation starts). FAB triggers navigation. Then the app becomes unresponsive to onPress events. Navigating back I can see that ripple effect got stuck (never finished) on a first button.
This PR might help with that too.
@RohovDmytro I think your issue is a different one from this, but I came across it today as well, and created a separate issue for it here: https://github.com/software-mansion/react-native-gesture-handler/issues/3370
This PR doesn't solve that bug however.
@latekvo Any progress on your end?
@oblador Apologies for the delayed response — I missed your earlier message. Unfortunately, I haven’t made any progress on this issue yet.
Hey! I merged https://github.com/software-mansion/react-native-gesture-handler/pull/3509, which addresses the same issue slightly differently. I'd love it if you could check if it solves the problem in your case.