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

[Gestures] PanResponder blocking child Touchable on 6s and 6s plus

Open deanmcpherson opened this issue 11 years ago • 40 comments

I'm trying to fix an issue in a library (https://github.com/dancormier/react-native-swipeout/issues/38) that appears to be broken on the 6s and 6s plus. The pan responder doesn't appear to allow touchable children to be pressed.

The library works on older devices with the same version of iOS, which makes me think that this has something to do with the new 3d touch hardware.

As noted in the other issue also, the library works in the emulator, but not the actual devices.

deanmcpherson avatar Sep 28 '15 01:09 deanmcpherson

+1 – We're also experiencing this problem on new 3d touch phones.

The nested touchable highlights don't react visually to touch, and aren't clickable, but tapping quickly a few times often ends up working.

aprilzero avatar Sep 28 '15 05:09 aprilzero

Could it be related to this iOS9 bug?

https://developer.apple.com/library/prerelease/ios/releasenotes/General/RN-iOSSDK-9.1/#//apple_ref/doc/uid/TP40016570-CH1-DontLinkElementID_25 — "touch pressure changes cause touchesMoved: to be called"

aprilzero avatar Sep 28 '15 05:09 aprilzero

Is this affecting anyone else? Or is PanResponder not really used often?

I'm worried that our app has become pretty much unusable for anyone with a new iPhone. Would love to find some sort of solution to this.

aprilzero avatar Sep 30 '15 23:09 aprilzero

+1 we are seeing the same thing here! @a2 @nicklockwood ideas?

myusuf3 avatar Sep 30 '15 23:09 myusuf3

We had a same problem, fortunately only on a few places so we could easily fix it by checking if dy/ dx is not 0 before granting a PanResponder in onMoveShouldSetPanResponder.

On the bottom of the page @aprilzero linked is written:

Apps should be prepared to receive touch move events with no change in the x/y coordinates.

I guess from now on we will just have to check for actual movement before granting.

meznaric avatar Oct 01 '15 10:10 meznaric

@meznaric 👏 thanks! That seems to fix the problem for us.

aprilzero avatar Oct 02 '15 19:10 aprilzero

Same issue here - but with Navigator. A button close to the edge of the screen stops working. I've tried setting 'gestures: null' the routes sceneConfig, but this actually stops taps from working at all (only force touch works).

jsierles avatar Oct 06 '15 16:10 jsierles

I tried the Navigator and react-native-swipeout and everything seemed to work as expected, can any of you guys provide a sample or more detailed repro steps?

tadeuzagallo avatar Oct 09 '15 12:10 tadeuzagallo

My issue is actually different. A button which is normally easy to tap has its tappable area shifted off to its left edge. Kust got an iPhone 6s now and will post more info soon.

jsierles avatar Oct 09 '15 15:10 jsierles

I think our flashcards are broken(not tappable) on 6s because of this. This is just a higher level guess will debug today.

chirag04 avatar Oct 09 '15 15:10 chirag04

I solved my problem: I had a TouchableOpacity with a nested wrapper view, and both the touchable and nested view had been set to position: absolute. I'm not sure yet why this would work on iPhone6 and not 6s - but will debug further and see if I can isolate a test case.

For now, here's a gist with the broken and fixed component:

https://gist.github.com/jsierles/6ea15850dab3c65dceeb

More details:

logging in Touchable.js touchableHandleResponderMove, the touchState for the broken component, when doing a single tap, always looks like this:

2015-10-09 18:29:53.204 [info][tid:com.facebook.React.JavaScript] 'RESPONDER_ACTIVE_PRESS_IN'
2015-10-09 18:29:53.222 [info][tid:com.facebook.React.JavaScript] 'RESPONDER_ACTIVE_PRESS_OUT'

The fixed component only sets RESPONDER_ACTIVE_PRESS_IN.

jsierles avatar Oct 09 '15 16:10 jsierles

I haven't had time to fully debug, but here's an example TouchableOpacity element that works on the iPhone6 but not 6s. You have to use a real device, not the simulator, to reproduce. Tapping on the large square fails ~80% of the time.

https://github.com/jsierles/RNiPhone6sTest

I fixed this by removing the redundant 'position: absolute' on the child view.

Maybe this can help get to the bottom of the issue.

jsierles avatar Oct 11 '15 19:10 jsierles

I just tried to debug this on 6s(had to buy a new one).

This is definitely a problem with position: absolute in child views. I have a setup like this:

<TouchableWithoutFeedback>
    <View>
        <View style={position: absolute}  />
        <View style={position: absolute}  />
    </View>
</TouchableWithoutFeedback>

Changing it to this fixes it:

<TouchableWithoutFeedback>
    <View>
        <View  />
        <View style={position: absolute}  />
    </View>
</TouchableWithoutFeedback>

Note: touchesMove is always called on 6s while it's not always called for iphone < 6.

cc @tadeuzagallo above setup should help debug. It works on simulator, you need a 6s to reproduce it.

chirag04 avatar Oct 16 '15 21:10 chirag04

My issue was resolved by @meznaric's comment

deanmcpherson avatar Oct 23 '15 05:10 deanmcpherson

i just find a not beautiful but convenient way to solve this problem(maxs15/react-native-modalbox#19) just use onPressIn not onPress in Touchable.*

h3l avatar Nov 18 '15 07:11 h3l

@meznaric's https://github.com/facebook/react-native/issues/3082#issuecomment-144689910 fixed the issue in my case.

I have side drawer with TouchableOpacity buttons and this PanResponder rule fixed the problem on iPhone 6s:

onMoveShouldSetPanResponderCapture: (evt, gestureState) => {
    return Math.abs(gestureState.dx) > 5;
},

:+1: :clap:

neciu avatar Dec 01 '15 10:12 neciu

@neciu it also solved it for me

ceichinger avatar Mar 02 '16 14:03 ceichinger

onMoveShouldSetPanResponderCapture: (evt, gestureState) => {
     return gestureState.dx != 0 && gestureState.dy != 0;
},

Worked for me (we are building a music player that drags up), the solution above with > 5 seemed to make the dragging action not sensitive enough.

beinginorbit avatar Mar 02 '16 17:03 beinginorbit

Worked--thanks everyone!

skleest avatar Mar 13 '16 02:03 skleest

Ran into this issue on a Note 5 running Android 5.1. Doesn't occur in the emulator but kills all Touchables when running on actual device.

@meznaric and @neciu solution fixed it right up. Thanks!

jawish avatar Mar 21 '16 11:03 jawish