fix(router-outlet): change detection fires properly (#18896)

* fix(router-outlet): never detach() the entering view

fixes #18894

* add tests

* ci

* update package-lock

* circle sync runtime
This commit is contained in:
Manu MA
2019-07-26 17:13:50 +02:00
committed by Liam DeBeasi
parent 462cee5b2e
commit 962783bfba
22 changed files with 3543 additions and 2728 deletions

View File

@ -44,7 +44,11 @@ export class StackController {
getExistingView(activatedRoute: ActivatedRoute): RouteView | undefined {
const activatedUrlKey = getUrl(this.router, activatedRoute);
return this.views.find(vw => vw.url === activatedUrlKey);
const view = this.views.find(vw => vw.url === activatedUrlKey);
if (view) {
view.ref.changeDetectorRef.reattach();
}
return view;
}
setActive(enteringView: RouteView): Promise<StackEvent> {
@ -55,6 +59,7 @@ export class StackController {
direction = 'back';
animation = undefined;
}
const viewsSnapshot = this.views.slice();
let currentNavigation;
@ -208,14 +213,19 @@ export class StackController {
this.skipTransition = false;
return Promise.resolve(false);
}
if (enteringView) {
enteringView.ref.changeDetectorRef.reattach();
if (leavingView === enteringView) {
return Promise.resolve(false);
}
// disconnect leaving page from change detection to
// reduce jank during the page transition
if (leavingView) {
leavingView.ref.changeDetectorRef.detach();
}
// In case the enteringView is the same as the leavingPage we need to reattach()
if (enteringView) {
enteringView.ref.changeDetectorRef.reattach();
}
const enteringEl = enteringView ? enteringView.element : undefined;
const leavingEl = leavingView ? leavingView.element : undefined;
const containerEl = this.containerEl;