Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
benadamstyles opened this issue May 8, 2017 · 15 comments
Closed
Labels
Bug Help Wanted :octocat: Issues ideal for external contributors. Resolution: Locked This issue was locked by the bot.

Comments

@benadamstyles
Copy link

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
@linoleum00
Copy link

In my case, the View inside the TouchableOpacity doesn't have the position absolute style, but if you press gently enough, it does work, but if you press normally then it doesn't work.

I have seen some post in which the solution is to use onPressIn instead, and it does the trick but when you have a bunch of touchables inside a scroll view, then you can't scroll because the onPressIn is called immediately after touched

@benadamstyles
Copy link
Author

I have seen some post in which the solution is to use onPressIn instead, and it does the trick

@linoleum00 Another related reason why this solution is unsatisfactory is that if you use onPressIn, the user can't cancel their tap by moving their finger away, which is a fundamental aspect of touch interaction.

@hramos hramos added the Icebox label Jul 20, 2017
@hramos
Copy link
Contributor

hramos commented Jul 20, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos closed this as completed Jul 20, 2017
@benadamstyles
Copy link
Author

This is still an issue, and I have reproduced it on React Native v0.47. All the information required is in my original post above. Lack of activity !== resolution!

@hramos hramos reopened this Aug 30, 2017
@IgorVanian
Copy link

This is a big issue still in RN49. Actually this looks like a solution but I guess it would be better to implement that inside RN itself.

@JLLLinn
Copy link

JLLLinn commented Dec 15, 2017

Still an issue in 0.51

@deepaksasken
Copy link

Yes, its still an issue in 0.51 :(

@hramos hramos added the Help Wanted :octocat: Issues ideal for external contributors. label Dec 22, 2017
@batmaster
Copy link

react-native: 0.51.0 still not work

@raimens
Copy link

raimens commented Jan 16, 2018

@hramos hramos removed the Icebox label Mar 8, 2018
@philvasseur
Copy link
Contributor

still not working in 0.53.3, no other solutions seem to work for me.

@ashishbista
Copy link

This is still an issue.

@kingr
Copy link

kingr commented Apr 25, 2018

Issue still exist.

@carmenchapa
Copy link

Still an issue.

@ghost
Copy link

ghost commented Jun 12, 2018

issue still exists on RN 0.55.4, none of the solutions mentioned in other threads are working when TouchableOpactity is rendered inside of position: 'absolute' View.

@cpojer
Copy link
Contributor

cpojer commented Apr 2, 2019

We noticed that very few people actually use 3D Touch so we recently removed a bunch of features related to it, so I'm going to close this as wontfix.

@cpojer cpojer closed this as completed Apr 2, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Apr 2, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Help Wanted :octocat: Issues ideal for external contributors. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests