fix(tabs): select whether the tabs is currently selected when activating it, so it knows to go to it's root page if so

This commit is contained in:
Dan Bucholtz
2018-02-23 15:41:14 -06:00
parent 5197358a3b
commit cc1fc2e032
2 changed files with 5 additions and 5 deletions

View File

@ -265,8 +265,8 @@ export class Nav implements PublicNav, NavOutlet {
} }
@Method() @Method()
activateFromTab() { activateFromTab(tabAlreadySelected: boolean) {
return activateFromTabImpl(this); return activateFromTabImpl(this, tabAlreadySelected);
} }
canSwipeBack(): boolean { canSwipeBack(): boolean {
@ -628,11 +628,11 @@ export function navigateToUrl(nav: Nav, url: string, _method: string): Promise<a
return nav.routerDelegate.pushUrlState(url); return nav.routerDelegate.pushUrlState(url);
} }
export function activateFromTabImpl(nav: Nav): Promise<any> { export function activateFromTabImpl(nav: Nav, tabAlreadySelected: boolean): Promise<any> {
return nav.onAllTransitionsComplete().then(() => { return nav.onAllTransitionsComplete().then(() => {
// if there is not a view set and it's not transitioning, // if there is not a view set and it's not transitioning,
// go ahead and set the root // go ahead and set the root
if (nav.getViews().length === 0 && !nav.isTransitioning()) { if ( (nav.getViews().length === 0 || tabAlreadySelected) && !nav.isTransitioning()) {
return nav.setRoot(nav.root); return nav.setRoot(nav.root);
} }

View File

@ -130,7 +130,7 @@ export class Tab {
// the tab's nav has not been initialized externally, so // the tab's nav has not been initialized externally, so
// check if we need to initiailize it // check if we need to initiailize it
return nav.componentOnReady() return nav.componentOnReady()
.then(() => nav.activateFromTab()); .then(() => nav.activateFromTab(this.selected));
}); });
} }