Description
Description
I'm trying to consolidate the various issues around this into one place so it can finally be tackled. The related issues I have found are:
The issue is that Touchable*#onPress
doesn't work on iOS devices with 3D Touch, if any pressure is applied, when the component wrapped by the Touchable*
has position: 'absolute'
. I think this has to do with touchmove
events (or equivalent) being triggered by 3D Touch (possibly in the z
direction?). A quick fix is to wrap your Touchable*
in a View
, giving this outer view position: 'absolute'
, and removing position: 'absolute'
from the View
inside your Touchable*
.
There is a related problem about the same incorrect behaviour applying to Touchable
s within a ScrollView (see * above) but this involves PanResponder
and becomes much more complicated. I have a feeling (totally unfounded) that fixing this bug might go some (or all the) way towards fixing that bug.
Reproduction Steps and Sample Code
// onPress never called if 3D Touch is present and any pressure is applied
<TouchableOpacity onPress={() => {}}>
<View style={{position: 'absolute'}}>
<Text>Press me</Text>
</View>
</TouchableOpacity>
Solution
I think this is a bug and requires either:
- Clear documentation telling the dev user that the first child of a
Touchable*
should not haveposition: 'absolute'
(but the parent can) - Or a
react-native
fix
Additional Information
- React Native version: 0.43.0
- Platform: iOS (3D Touch enabled devices)
- Development Operating System: macOS