Skip to content

Commit cb65f79

Browse files
committed
fix(tabs): _touchActive() works when tab.root is a string
1 parent 8efffff commit cb65f79

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/components/tabs/tabs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Ion } from '../ion';
77
import { isBlank } from '../../util/util';
88
import { NavController } from '../../navigation/nav-controller';
99
import { NavControllerBase } from '../../navigation/nav-controller-base';
10-
import { NavOptions, DIRECTION_SWITCH } from '../../navigation/nav-util';
10+
import { getComponent, NavOptions, DIRECTION_SWITCH } from '../../navigation/nav-util';
1111
import { Platform } from '../../platform/platform';
1212
import { Tab } from './tab';
1313
import { TabHighlight } from './tab-highlight';
@@ -501,9 +501,9 @@ export class Tabs extends Ion implements AfterViewInit {
501501

502502
} else if (tab.length() > 1) {
503503
// if we're a few pages deep, pop to root
504-
tab.popToRoot(null, null);
504+
tab.popToRoot();
505505

506-
} else if (tab.root !== active.component) {
506+
} else if (getComponent(this._linker, tab.root) !== active.component) {
507507
// Otherwise, if the page we're on is not our real root, reset it to our
508508
// default root type
509509
tab.setRoot(tab.root);

src/navigation/nav-util.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,25 @@ import { NavControllerBase } from './nav-controller-base';
77
import { Transition } from '../transitions/transition';
88

99

10+
export function getComponent(linker: DeepLinker, nameOrPageOrView: any): any {
11+
if (typeof nameOrPageOrView === 'function') {
12+
return nameOrPageOrView;
13+
}
14+
if (typeof nameOrPageOrView === 'string') {
15+
return linker.getComponentFromName(nameOrPageOrView);
16+
}
17+
return null;
18+
}
19+
1020
export function convertToView(linker: DeepLinker, nameOrPageOrView: any, params: any): ViewController {
1121
if (nameOrPageOrView) {
1222
if (isViewController(nameOrPageOrView)) {
1323
// is already a ViewController
1424
return nameOrPageOrView;
1525
}
16-
if (typeof nameOrPageOrView === 'function') {
17-
// is a page component, now turn it into a ViewController
18-
return new ViewController(nameOrPageOrView, params);
19-
}
20-
if (typeof nameOrPageOrView === 'string') {
21-
// is a string, see if it matches a
22-
const component = linker.getComponentFromName(nameOrPageOrView);
23-
if (component) {
24-
// found a page component in the link config by name
25-
return new ViewController(component, params);
26-
}
26+
let component = getComponent(linker, nameOrPageOrView);
27+
if (component) {
28+
return new ViewController(component, params);
2729
}
2830
}
2931
console.error(`invalid page component: ${nameOrPageOrView}`);
@@ -77,17 +79,17 @@ export function setZIndex(nav: NavControllerBase, enteringView: ViewController,
7779
}
7880
}
7981

80-
export function isTabs(nav: any) {
82+
export function isTabs(nav: any): boolean {
8183
// Tabs (ion-tabs)
8284
return !!nav && !!nav.getSelected;
8385
}
8486

85-
export function isTab(nav: any) {
87+
export function isTab(nav: any): boolean {
8688
// Tab (ion-tab)
8789
return !!nav && isPresent(nav._tabId);
8890
}
8991

90-
export function isNav(nav: any) {
92+
export function isNav(nav: any): boolean {
9193
// Nav (ion-nav), Tab (ion-tab), Portal (ion-portal)
9294
return !!nav && !!nav.push;
9395
}

0 commit comments

Comments
 (0)