[ReactNative] Navigator improved willFocus logic
Summary: This makes sure to call willFocus before new scenes get mounted. This fixes cases where the keyboard is dismissed on willfocus events which incorrectly happens *after* the autofocus in a new scene. The keyboard was opening and getting immediately closed @public Test Plan: Test keyboard autofocus in new nav scenes on iOS
This commit is contained in:
parent
7159a4e947
commit
e3e60983e6
|
@ -392,7 +392,6 @@ var Navigator = React.createClass({
|
||||||
this.spring.getSpringConfig().tension = sceneConfig.springTension;
|
this.spring.getSpringConfig().tension = sceneConfig.springTension;
|
||||||
this.spring.setVelocity(velocity || sceneConfig.defaultTransitionVelocity);
|
this.spring.setVelocity(velocity || sceneConfig.defaultTransitionVelocity);
|
||||||
this.spring.setEndValue(1);
|
this.spring.setEndValue(1);
|
||||||
this._emitWillFocus(this.state.routeStack[this.state.presentedIndex]);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,6 +457,7 @@ var Navigator = React.createClass({
|
||||||
if (this.state.transitionQueue.length) {
|
if (this.state.transitionQueue.length) {
|
||||||
var queuedTransition = this.state.transitionQueue.shift();
|
var queuedTransition = this.state.transitionQueue.shift();
|
||||||
this._enableScene(queuedTransition.destIndex);
|
this._enableScene(queuedTransition.destIndex);
|
||||||
|
this._emitWillFocus(this.state.routeStack[queuedTransition.destIndex]);
|
||||||
this._transitionTo(
|
this._transitionTo(
|
||||||
queuedTransition.destIndex,
|
queuedTransition.destIndex,
|
||||||
queuedTransition.velocity,
|
queuedTransition.velocity,
|
||||||
|
@ -657,6 +657,7 @@ var Navigator = React.createClass({
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The gesture has enough velocity to complete, so we transition to the gesture's destination
|
// The gesture has enough velocity to complete, so we transition to the gesture's destination
|
||||||
|
this._emitWillFocus(this.state.routeStack[destIndex]);
|
||||||
this._transitionTo(
|
this._transitionTo(
|
||||||
destIndex,
|
destIndex,
|
||||||
transitionVelocity,
|
transitionVelocity,
|
||||||
|
@ -844,6 +845,7 @@ var Navigator = React.createClass({
|
||||||
_jumpN: function(n) {
|
_jumpN: function(n) {
|
||||||
var destIndex = this._getDestIndexWithinBounds(n);
|
var destIndex = this._getDestIndexWithinBounds(n);
|
||||||
this._enableScene(destIndex);
|
this._enableScene(destIndex);
|
||||||
|
this._emitWillFocus(this.state.routeStack[destIndex]);
|
||||||
this._transitionTo(destIndex);
|
this._transitionTo(destIndex);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -876,6 +878,7 @@ var Navigator = React.createClass({
|
||||||
var nextAnimationConfigStack = activeAnimationConfigStack.concat([
|
var nextAnimationConfigStack = activeAnimationConfigStack.concat([
|
||||||
this.props.configureScene(route),
|
this.props.configureScene(route),
|
||||||
]);
|
]);
|
||||||
|
this._emitWillFocus(nextStack[destIndex]);
|
||||||
this.setState({
|
this.setState({
|
||||||
idStack: nextIDStack,
|
idStack: nextIDStack,
|
||||||
routeStack: nextStack,
|
routeStack: nextStack,
|
||||||
|
@ -896,6 +899,7 @@ var Navigator = React.createClass({
|
||||||
);
|
);
|
||||||
var popIndex = this.state.presentedIndex - n;
|
var popIndex = this.state.presentedIndex - n;
|
||||||
this._enableScene(popIndex);
|
this._enableScene(popIndex);
|
||||||
|
this._emitWillFocus(this.state.routeStack[popIndex]);
|
||||||
this._transitionTo(
|
this._transitionTo(
|
||||||
popIndex,
|
popIndex,
|
||||||
null, // default velocity
|
null, // default velocity
|
||||||
|
@ -935,13 +939,15 @@ var Navigator = React.createClass({
|
||||||
nextRouteStack[index] = route;
|
nextRouteStack[index] = route;
|
||||||
nextAnimationModeStack[index] = this.props.configureScene(route);
|
nextAnimationModeStack[index] = this.props.configureScene(route);
|
||||||
|
|
||||||
|
if (index === this.state.presentedIndex) {
|
||||||
|
this._emitWillFocus(route);
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
idStack: nextIDStack,
|
idStack: nextIDStack,
|
||||||
routeStack: nextRouteStack,
|
routeStack: nextRouteStack,
|
||||||
sceneConfigStack: nextAnimationModeStack,
|
sceneConfigStack: nextAnimationModeStack,
|
||||||
}, () => {
|
}, () => {
|
||||||
if (index === this.state.presentedIndex) {
|
if (index === this.state.presentedIndex) {
|
||||||
this._emitWillFocus(route);
|
|
||||||
this._emitDidFocus(route);
|
this._emitDidFocus(route);
|
||||||
}
|
}
|
||||||
cb && cb();
|
cb && cb();
|
||||||
|
|
Loading…
Reference in New Issue