From b3886652ab96fda55ed579abb54344178ddcf877 Mon Sep 17 00:00:00 2001 From: Fred Liu Date: Wed, 22 Jun 2016 11:00:17 -0700 Subject: [PATCH] Fix navigation jump on multi-tap Summary: On iOS, if a non-selected breadcrumb is tapped multiple times, the navigator will transition to the tapped breadcrumb, then back to the previously selected breadcrumb. Then, when another breadcrumb is tapped, it would go to the previously multi-tapped breadcrumb. This seems to be because transitions are queued when they shouldn't be. I've reverted to the way it was before PR 8701, but added a `transitionQueue.length === 0`. This should solve the race condition from 8701, ensuring all transitions in the queue are flushed in sequence, and thus landing on the finally tapped one. Reviewed By: hedgerwang Differential Revision: D3469901 fbshipit-source-id: 0143a27d6c875d47d28b77eed4e5a28b1c40c8bb --- Libraries/CustomComponents/Navigator/Navigator.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Libraries/CustomComponents/Navigator/Navigator.js b/Libraries/CustomComponents/Navigator/Navigator.js index 84a077899..c855a94df 100644 --- a/Libraries/CustomComponents/Navigator/Navigator.js +++ b/Libraries/CustomComponents/Navigator/Navigator.js @@ -373,6 +373,12 @@ var Navigator = React.createClass({ }, _transitionTo: function(destIndex, velocity, jumpSpringTo, cb) { + if ( + destIndex === this.state.presentedIndex && + this.state.transitionQueue.length === 0 + ) { + return; + } if (this.state.transitionFromIndex !== null) { this.state.transitionQueue.push({ destIndex, @@ -381,9 +387,7 @@ var Navigator = React.createClass({ }); return; } - if (destIndex === this.state.presentedIndex) { - return; - } + this.state.transitionFromIndex = this.state.presentedIndex; this.state.presentedIndex = destIndex; this.state.transitionCb = cb;