react-native: Long press broken for TouchableNativeFeedback

๐Ÿ› Bug Report

After upgrading from React Native 0.58.6 to 0.59.1, any <TouchableNativeFeedback /> with onLongPress is no longer working i.e. the handler is never fired.

To Reproduce

Use TouchableNativeFeedback with onLongPress in a React Native 0.59.1 app.

Expected Behavior

Long pressing the TouchableNativeFeedback triggers the onLongPress handler

Code Example

https://github.com/mjmasn/rn59_tnf_longpress

Environment

info 
  React Native Environment Info:
    System:
      OS: Linux 4.15 Ubuntu 16.04.6 LTS (Xenial Xerus)
      CPU: (8) x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
      Memory: 856.03 MB / 15.54 GB
      Shell: 4.3.48 - /bin/bash
    Binaries:
      Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
      Yarn: 1.15.2 - /usr/bin/yarn
      npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      Android SDK:
        API Levels: 16, 19, 22, 23, 26, 27, 28
        Build Tools: 23.0.1, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.3, 28.0.2, 28.0.3
        System Images: android-16 | Google APIs Intel x86 Atom, android-17 | Google APIs Intel x86 Atom, android-18 | Google APIs Intel x86 Atom, android-19 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64
    IDEs:
      Android Studio: 3.1 AI-173.4907809
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.1 => 0.59.1 
    npmGlobalPackages:
      create-react-native-app: 2.0.2
      react-native-cli: 2.0.1
      react-native-create-library: 3.1.2
      react-native-git-upgrade: 0.2.7

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 24 (13 by maintainers)

Most upvoted comments

Wanted to update, the issue on 0.59.10 only seemed to happen when remote-debugging was turned on, onPress would trigger onLongPress instead

However, after upgrading to RN 0.60.0, onLongPress on touchableOpacity is not working at all when using remote debugger.

works fine when not debugging

@rickhanlonii hmm actually it looks like your commit here might have triggered this: https://github.com/facebook/react-native/commit/3bef4bddbfbdaaa7f431bbada5d72c26e01a45d6#diff-580446e098bcae0cd35585b8cf689f2aL501

Apparently that line was not just a perf optimisation ๐Ÿ™ƒ

RN 0.59.2 ,This bug still exists

also affecting TouchableHighlight on iOS

Thanks @rickhanlonii ๐Ÿ‘

One final piece of information: the issue is also affecting <TouchableHighlight /> in the same way.

<TouchableOpacity /> and <TouchableWithoutFeedback /> are not affected.

Hey @mjmasn, thanks for more testing!

Re-opening so we can test on those devices and figure out whatโ€™s happening

Confirmed broken on 0.59.10 on a Pixel 3 XL using TouchableOpacity

@rickhanlonii hmm actually it looks like your commit here might have triggered this: 3bef4bd#diff-580446e098bcae0cd35585b8cf689f2aL501

Apparently that line was not just a perf optimisation ๐Ÿ™ƒ

FYI. Just forked a private repo to revert this commit. It is confirmed that commit causes the issue.

Working on emulators: Nexus_5X_API_25 Nexus_6P_API_26 Pixel_C_API_27 Pixel_2_XL_API_28

Working on real devices: LGE Nexus 5 running Android 6.0.1 (API 23) Huawei P8 lite 2017 running Android 7.0 (API 24) LGE Nexus 5X running Android 8.1.0 (API 27)

Broken on real devices: Samsung Galaxy A5 (2016) running Android 7.0 (API 24) Samsung Galaxy S9+ running Android 9 (API 28)

Possibly a Samsung theme here but I donโ€™t have any other devices to hand. Would be helpful if other Samsung users could chime inโ€ฆ

@rickhanlonii hmm, itโ€™s broken on a variety of real devices in our office. Could be a specific Android version maybe? I havenโ€™t tried any emulators yet but will do so this afternoon. The issue does appear to be intermittent, sometimes after a few attempts it does trigger the onLongPress handler but itโ€™s probably 1 in 10 attempts or fewer.

Iโ€™m running Android 9 on a Samsung Galaxy S9+