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

touchableWithoutFeedback onPress and onPressOut not firing on Android #10180

Closed
larryranches opened this issue Sep 30, 2016 · 25 comments
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@larryranches
Copy link

Issue Description

touchableWithoutFeedback onPress and onPressOut function are not firing on Android specifically the Samsung Galaxy.

This is working perfectly fine on IOS10.

Steps to Reproduce / Code Snippets

Code snippet of using the onPressOut function

<TouchableWithoutFeedback onPressOut={ this.onStopRecording }>

Expected Results

function should fire on Android. Is working for IOS!

Additional Information

  • React Native version: 0.33
  • Platform(s) (iOS, Android, or both?): ANDROID
    Operating System (macOS, Linux, or Windows?): OSX
@larryranches
Copy link
Author

Also not working on Nexus 5x. Any ideas? Seems to be only android related.

@marcshilling
Copy link

marcshilling commented Oct 6, 2016

I've been having similar issues with <TouchableWithoutFeedback> on iOS as well. RN 0.34.1.

I've fallen back to just using <TouchableOpacity> with activeOpacity: 1

@AndrewHenderson
Copy link

I found the following did not work with TouchableWithoutFeedback but is working with TouchableOpacity on React Native 0.37.0:

return (
  <View style={styles.sceneContent}>
    <ScrollView>
      <TouchableOpacity
        onPress={this.handlePersonPress.bind(this)}
      >
        <PersonHeading
          photoUrl={this.state.person.photoUrl}
          name={this.state.person.firstName}
        />
      </TouchableOpacity>
      <Image
        style={{height: 250}}
        source={{uri: this.props.photoUrl}}
      />
      <View style={styles.eventContent}>
        <Text style={[styles.h2, styles.centerText]}>{this.props.description}</Text>
        <Text style={[styles.h3, styles.centerText]}>{this.props.location}</Text>
        <Text style={[styles.centerText]}>{renderTime(this.props.startTime)}</Text>
        <Text style={[styles.centerText]}>{renderTime(this.props.endTime)}</Text>
      </View>
      <View style={styles.scenePad}>
        <Button
          style={[styles.button, styles.backgroundBlue]}
        >
          Request to Join
        </Button>
      </View>
    </ScrollView>
  </View>
);

I wonder if it has something to do with being nested within the ScrollView, since I have it working fine in another component that is not the direct descendent of a ScrollView.

I'll upgrade to the latest version and update this comment with the results.

@CorentinDeBoisset
Copy link

CorentinDeBoisset commented Feb 15, 2017

It is working for me today, maybe it was solved in more recent versions (tested on 0.41 on the android emulator).

@benjaminreid
Copy link

I've ran into this today, TouchableWithoutFeedback was working perfectly fine until it wasn’t. RN 0.41 and running in the up to date iOS simulator. Very bizarre.

@larryranches
Copy link
Author

Any ideas on this? The onPressOut is still not firing only for Android. Working perfect on ios still. I'm now on RN 0.43

@koenpunt
Copy link
Contributor

koenpunt commented May 1, 2017

I found that TouchableWithoutFeedback always needs to have child View component. So a component that composes a View isn't enough.

So instead of

<TouchableWithoutFeedback onPressIn={...} onPressOut={...} onPress={...}>
  <MyCustomComponent />
</TouchableWithoutFeedback>

I now use:

<TouchableWithoutFeedback onPressIn={...} onPressOut={...} onPress={...}>
  <View>
    <MyCustomComponent />
  </View>
</TouchableWithoutFeedback>

@oliverbenns
Copy link

oliverbenns commented May 18, 2017

Fixed my issue thanks @koenpunt . Kind of depressing though.

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

mgagnon555 commented Nov 20, 2017

It is not fixed (RN 0.49.3), unless "having to add a and then it works" is considered fixed. The only child my TouchableWithoutFeedback had is a custom Header extending Component. Adding a View works but ... why?

@spearmootz
Copy link

yep. im having this issue right now. adding the view works but it messes up everything

@nicolasconnault
Copy link

Problem is still there, solution still works.

@Elijen
Copy link

Elijen commented Jan 20, 2018

@hramos Reopen so issues can actually get fixed?

@bala-compassites
Copy link

Its not working. Problem is still there.

@rafaelgrilli92
Copy link

@koenpunt approach worked for me.

@robhung
Copy link

robhung commented Feb 27, 2018

It's strange because I've made a component that renders a <View> with pre-configured styles and even then, it doesn't work. It needs a completely new <View component for this to work.

RN 0.49.5

@katerynkas
Copy link

Not working for me too even with a View component inside.

@TheDutchCoder
Copy link

Still not working on RN 0.53.0

@Elijen
Copy link

Elijen commented Mar 7, 2018

I am sure any contributors already muted this issue so bumping it is pointless. Just use <View> component inside as @koenpunt suggested. If it's not working even with it, open a new issue.

@TheDutchCoder
Copy link

Okay I figured out the issue, it's that the component itself does not support proper styling and collapses around its child view.

Not sure if that's by design or not (all other touchables are properly stylable), so I'll open an issue for it.

@jayasme
Copy link

jayasme commented Mar 8, 2018

You must put something into it to make it work, just put a <View> and wrap your JSX into the view is the first step, the next is making the view flex=1

<TouchableWithoutFeedback>
    <View style={{flex:1}}>
         ... your actual JSX
    </View>
</TouchableWithoutFeedback>

Using this component is like a nightmare.

@TheDutchCoder
Copy link

Yeah it's wildly inconsistent right now, it should be fixed so it behaves like other Touchables.

@rmacqueen
Copy link

Also ran into this - it's quite frustrating to have to include the additional gratuitous View. I opened #18611 as a follow-up since this one was prematurely closed.

@pintocarlos
Copy link

I have this issue also, using 0.54
I had to add the extra View which is a shame.

@dazweeja
Copy link

dazweeja commented Jul 9, 2018

For the record, it's not necessary to add an extra view, you just need to ensure that the props that TouchableWithoutFeedback injects into it's child component are passed down to the View inside your custom component. For example, your custom component might be something like this:

<View {...this.props}>
  ... etc
</View>

It's explained in #1352

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
qwertychouskie referenced this issue in dohooo/react-native-reanimated-carousel Sep 14, 2024
Import TouchableWithoutFeedback from react-native instead of react-native-gesture-handler to solve Error: NativeViewGestureHandler must be used as a descendant of GestureHandlerRootView
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests