Skip to content

Touchable onPress not working with 3D Touch when 'position: absolute' #13845

Closed
@benadamstyles

Description

@benadamstyles

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:

#3082 *
#10822
#10386

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 Touchables 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 have position: '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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugHelp Wanted :octocat:Issues ideal for external contributors.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions