diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 0a2f554c4..0493311c5 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -456,6 +456,11 @@ var TouchableMixin = { pressExpandBottom; if (isTouchWithinActive) { this._receiveSignal(Signals.ENTER_PRESS_RECT, e); + var curState = this.state.touchable.touchState; + if (curState === States.RESPONDER_INACTIVE_PRESS_IN) { + // fix for t7967420 + this._cancelLongPressDelayTimeout(); + } } else { this._cancelLongPressDelayTimeout(); this._receiveSignal(Signals.LEAVE_PRESS_RECT, e); @@ -564,7 +569,20 @@ var TouchableMixin = { _handleLongDelay: function(e) { this.longPressDelayTimeout = null; - this._receiveSignal(Signals.LONG_PRESS_DETECTED, e); + var curState = this.state.touchable.touchState; + if (curState !== States.RESPONDER_ACTIVE_PRESS_IN && + curState !== States.RESPONDER_ACTIVE_LONG_PRESS_IN) { + if (__DEV__) { + throw new Error( + 'Attempted to transition from state `' + curState + '` to `' + + States.RESPONDER_ACTIVE_LONG_PRESS_IN + '`, which is not supported. ' + + 'This is most likely due to `Touchable.longPressDelayTimeout` not ' + + 'being cancelled.' + ); + } + } else { + this._receiveSignal(Signals.LONG_PRESS_DETECTED, e); + } }, /** @@ -577,13 +595,13 @@ var TouchableMixin = { */ _receiveSignal: function(signal, e) { var curState = this.state.touchable.touchState; - if (!(Transitions[curState] && Transitions[curState][signal])) { + var nextState = Transitions[curState] && Transitions[curState][signal]; + if (!nextState) { throw new Error( 'Unrecognized signal `' + signal + '` or state `' + curState + '` for Touchable responder `' + this.state.touchable.responderID + '`' ); } - var nextState = Transitions[curState][signal]; if (nextState === States.ERROR) { throw new Error( 'Touchable cannot transition from `' + curState + '` to `' + signal +