fix(angular): nested tabs now go to correct page (#23902)

resolves #23897
This commit is contained in:
Liam DeBeasi
2021-09-09 14:06:43 -04:00
committed by GitHub
parent 47829690b5
commit 1ed9f07060

View File

@ -86,10 +86,20 @@ export class IonTabs {
* b. If the last route view doesn't exist, then navigate
* to the default tabRootUrl
*/
@HostListener('ionTabButtonClick', ['$event.detail.tab'])
select(tab: string) {
@HostListener('ionTabButtonClick', ['$event'])
select(ev: CustomEvent) {
const tab = ev.detail.tab;
const alreadySelected = this.outlet.getActiveStackId() === tab;
const tabRootUrl = `${this.outlet.tabsPrefix}/${tab}`;
/**
* If this is a nested tab, prevent the event
* from bubbling otherwise the outer tabs
* will respond to this event too, causing
* the app to get directed to the wrong place.
*/
ev.stopPropagation();
if (alreadySelected) {
const activeStackId = this.outlet.getActiveStackId();
const activeView = this.outlet.getLastRouteView(activeStackId);