react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Android] TouchableNativeFeedback doesn't forward touch event

Open mangogogos opened this issue 10 years ago • 1 comments

I came across this issue and after a little peek into the source code noticed that the presshandlers in TouchableNativeFeedback don't capture or pass on the touch event parameter. Compare:

TouchableOpacity.js:109

touchableHandlePress: function(e: Event) {
    this.clearTimeout(this._hideTimeout);
    this._opacityActive();
    this._hideTimeout = this.setTimeout(
      this._opacityInactive,
      this.props.delayPressOut || 100
    );
    this.props.onPress && this.props.onPress(e);
  }

to

TouchableNativeFeedback.js:152

touchableHandlePress: function() {
  this.props.onPress && this.props.onPress();
},

That particular function in TouchableNativeFeedback hasn't been touched since RN for Android was first released so I was surprised to not see any issues (that I noticed) documenting this.

I can open up a PR but since this code is so old, relatively, I thought I'd ask first to see if there were any reasons why this wasn't done initially? Potential bugs, crashes etc.

FWIW, simply adding an e into the parameter list and the onPress function call correctly forwarded the touch event so I've got this working for my local use case

mangogogos avatar Mar 03 '16 01:03 mangogogos

Sounds like a good idea, thank you for noticing this! Can you send a PR please and link to this issue so it gets closed once the PR is merged?

mkonicek avatar Mar 04 '16 15:03 mkonicek