mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
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:
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user