Skip to content

Commit

Permalink
fixed touchable longpress (#24238)
Browse files Browse the repository at this point in the history
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: #24238

Reviewed By: cpojer

Differential Revision: D14712986

Pulled By: rickhanlonii

fbshipit-source-id: e85a66a7e8b61e0a33146b2472e2e055726a0e93
  • Loading branch information
Kida007 authored and grabbou committed Apr 8, 2019
1 parent 836a8e0 commit 05723ed
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Libraries/Components/Touchable/Touchable.js
Expand Up @@ -484,13 +484,15 @@ 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);
},

/**
* Place as callback for a DOM element's `onResponderTerminate` event.
*/
touchableHandleResponderTerminate: function(e: PressEvent) {
this.pressInLocation = null;
this._receiveSignal(Signals.RESPONDER_TERMINATED, e);
},

Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 05723ed

Please sign in to comment.