Skip to content

Commit 56dd8ae

Browse files
committed
feat(angular): tabs.select()
fixes #16753
1 parent 60ef98d commit 56dd8ae

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

angular/src/directives/navigation/ion-router-outlet.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
197197
const active = this.stackCtrl.getLastUrl(stackId);
198198
return active ? active.url : undefined;
199199
}
200+
201+
getActiveStackId() {
202+
return this.stackCtrl.getActiveStackId();
203+
}
200204
}
201205

202206
function emitEvent(el: HTMLElement, view: RouteView) {

angular/src/directives/navigation/ion-tabs.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Component, ContentChild, HostListener, ViewChild } from '@angular/core';
2-
import { TabButtonClickDetail } from '@ionic/core';
32

43
import { NavController } from '../../providers';
54
import { IonTabBar } from '../proxies';
@@ -57,14 +56,14 @@ export class IonTabs {
5756
}
5857
}
5958

60-
@HostListener('ionTabButtonClick', ['$event.detail'])
61-
onTabButtonClick(detail: TabButtonClickDetail) {
62-
const { tab, selected } = detail;
59+
@HostListener('ionTabButtonClick', ['$event.detail.tab'])
60+
select(tab: string) {
61+
const selected = this.outlet.getActiveStackId() === tab;
6362
const href = `${this.outlet.tabsPrefix}/${tab}`;
6463
const url = selected
6564
? href
6665
: this.outlet.getLastUrl(tab) || href;
6766

68-
this.navCtrl.navigateBack(url, true);
67+
return this.navCtrl.navigateBack(url, true);
6968
}
7069
}

angular/src/directives/navigation/stack-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class StackController {
9090
return views.length > 0 ? views[views.length - 1] : undefined;
9191
}
9292

93-
private getActiveStackId(): string | undefined {
93+
getActiveStackId(): string | undefined {
9494
return this.activeView ? this.activeView.stackId : undefined;
9595
}
9696

0 commit comments

Comments
 (0)