fix(react): support for 'root' router direction, fixes #19982 (#20052)

This commit is contained in:
Ely Lucas
2019-12-09 17:23:39 -07:00
committed by Ely Lucas
parent 43712db1be
commit 4d226b05c6
4 changed files with 22 additions and 6 deletions

View File

@ -88,7 +88,7 @@ class RouteManager extends React.Component<RouteComponentProps, RouteManagerStat
}
historyChange(location: HistoryLocation, action: HistoryAction) {
const ionRouteAction = this.currentIonRouteAction === 'pop' ? 'pop' : action.toLowerCase();
const ionRouteAction = this.currentIonRouteAction === 'pop' ? 'pop' : action.toLowerCase() as IonRouteAction;
let direction = this.currentRouteDirection;
if (ionRouteAction === 'push') {
@ -101,6 +101,11 @@ class RouteManager extends React.Component<RouteComponentProps, RouteManagerStat
direction = 'none';
}
if (direction === 'root') {
this.locationHistory.clear();
this.locationHistory.add(location);
}
location.state = location.state || { direction };
this.setState({
location,
@ -175,8 +180,15 @@ class RouteManager extends React.Component<RouteComponentProps, RouteManagerStat
const enteringEl = this.ionPageElements[enteringView.id];
const leavingEl = leavingView && this.ionPageElements[leavingView.id];
if (enteringEl) {
// Don't animate from an empty view
const navDirection = leavingEl && leavingEl.innerHTML === '' ? undefined : direction === 'none' ? undefined : direction;
let navDirection: NavDirection | undefined;
if (leavingEl && leavingEl.innerHTML === '') {
// Don't animate from an empty view
navDirection = undefined;
} else if (direction === 'none' || direction === 'root') {
navDirection = undefined;
} else {
navDirection = direction;
}
const shouldGoBack = !!enteringView.prevId;
const routerOutlet = this.routerOutlets[viewStack.id];
this.commitView(