From 2bd89feb0f14562a1f2c8f86cd4c6b3ecc4862e9 Mon Sep 17 00:00:00 2001 From: Dan Bucholtz Date: Tue, 3 Oct 2017 12:32:47 -0500 Subject: [PATCH] fix(navigation): unregister root navs when appropriate --- src/components/app/app.ts | 7 +++++++ src/components/tabs/tabs.ts | 6 +++++- src/navigation/nav-controller-base.ts | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/app/app.ts b/src/components/app/app.ts index 9cdfddd293d..a33b8b01100 100644 --- a/src/components/app/app.ts +++ b/src/components/app/app.ts @@ -274,6 +274,13 @@ export class App { this._rootNavs.set(nav.id, nav); } + /** + * @hidden + */ + unregisterRootNav(nav: NavigationContainer) { + this._rootNavs.delete(nav.id); + } + getActiveNavContainers(): NavigationContainer[] { // for each root nav container, get it's active nav diff --git a/src/components/tabs/tabs.ts b/src/components/tabs/tabs.ts index 1ec729995e5..b4ba46f5520 100644 --- a/src/components/tabs/tabs.ts +++ b/src/components/tabs/tabs.ts @@ -301,7 +301,11 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs, Navigat */ ngOnDestroy() { this._onDestroy.next(); - this.parent.unregisterChildNav(this); + if (this.parent) { + this.parent.unregisterChildNav(this); + } else { + this._app.unregisterRootNav(this); + } } /** diff --git a/src/navigation/nav-controller-base.ts b/src/navigation/nav-controller-base.ts index 86daddb2d2c..2bf1ac596a3 100644 --- a/src/navigation/nav-controller-base.ts +++ b/src/navigation/nav-controller-base.ts @@ -1025,6 +1025,8 @@ export class NavControllerBase extends Ion implements NavController { // Unregister navcontroller if (this.parent && this.parent.unregisterChildNav) { this.parent.unregisterChildNav(this); + } else if (this._app) { + this._app.unregisterRootNav(this); } this._destroyed = true;