Skip to content

Commit

Permalink
fix(navigation): unregister root navs when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
danbucholtz committed Oct 5, 2017
1 parent c38cc28 commit 2bd89fe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/components/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/components/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/navigation/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2bd89fe

Please sign in to comment.