fixed touchable longpress (#24238)

Summary:
This diff fixes a bug in TouchableNativeFeedback where a long press is not registered.

cause of the bug is _touchableHandleResponderMove_ being invoked **regardless** of a moving gesture ( even when movedDistance is 0) in some devices ( including OnePlus5t ), which was eventually clearing out  the long-press timeout.

fix is to prevent _touchableHandleResponderMove_ from Implementing if the state of touchable is RESPONDER_INACTIVE_PRESS_IN.

[General] [Fixed] - Touchable onLongPress fix.
Pull Request resolved: https://github.com/facebook/react-native/pull/24238

Reviewed By: cpojer

Differential Revision: D14712986

Pulled By: rickhanlonii

fbshipit-source-id: e85a66a7e8b61e0a33146b2472e2e055726a0e93
This commit is contained in:
PIYUSH GUPTA 2019-04-03 10:30:07 -07:00 committed by Mike Grabowski
parent 836a8e0e4d
commit 05723ed08a
1 changed files with 7 additions and 1 deletions

View File

@ -484,6 +484,7 @@ const TouchableMixin = {
* Place as callback for a DOM element's `onResponderRelease` event.
*/
touchableHandleResponderRelease: function(e: PressEvent) {
this.pressInLocation = null;
this._receiveSignal(Signals.RESPONDER_RELEASE, e);
},
@ -491,6 +492,7 @@ const TouchableMixin = {
* Place as callback for a DOM element's `onResponderTerminate` event.
*/
touchableHandleResponderTerminate: function(e: PressEvent) {
this.pressInLocation = null;
this._receiveSignal(Signals.RESPONDER_TERMINATED, e);
},
@ -558,9 +560,13 @@ const TouchableMixin = {
dimensionsOnActivate.height +
pressExpandBottom;
if (isTouchWithinActive) {
const prevState = this.state.touchable.touchState;
this._receiveSignal(Signals.ENTER_PRESS_RECT, e);
const curState = this.state.touchable.touchState;
if (curState === States.RESPONDER_INACTIVE_PRESS_IN) {
if (
curState === States.RESPONDER_INACTIVE_PRESS_IN &&
prevState !== States.RESPONDER_INACTIVE_PRESS_IN
) {
// fix for t7967420
this._cancelLongPressDelayTimeout();
}