From 59e50237bff9521d2b78d7576abf4e23d844ac1b Mon Sep 17 00:00:00 2001 From: PIYUSH GUPTA Date: Wed, 3 Apr 2019 10:30:07 -0700 Subject: [PATCH] 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 --- Libraries/Components/Touchable/Touchable.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 72f7e4c35033f5..03aeeb9261b444 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -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(); }