mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(tabs): _touchActive() works when tab.root is a string
This commit is contained in:
@ -7,7 +7,7 @@ import { Ion } from '../ion';
|
||||
import { isBlank } from '../../util/util';
|
||||
import { NavController } from '../../navigation/nav-controller';
|
||||
import { NavControllerBase } from '../../navigation/nav-controller-base';
|
||||
import { NavOptions, DIRECTION_SWITCH } from '../../navigation/nav-util';
|
||||
import { getComponent, NavOptions, DIRECTION_SWITCH } from '../../navigation/nav-util';
|
||||
import { Platform } from '../../platform/platform';
|
||||
import { Tab } from './tab';
|
||||
import { TabHighlight } from './tab-highlight';
|
||||
@ -501,9 +501,9 @@ export class Tabs extends Ion implements AfterViewInit {
|
||||
|
||||
} else if (tab.length() > 1) {
|
||||
// if we're a few pages deep, pop to root
|
||||
tab.popToRoot(null, null);
|
||||
tab.popToRoot();
|
||||
|
||||
} else if (tab.root !== active.component) {
|
||||
} else if (getComponent(this._linker, tab.root) !== active.component) {
|
||||
// Otherwise, if the page we're on is not our real root, reset it to our
|
||||
// default root type
|
||||
tab.setRoot(tab.root);
|
||||
|
@ -7,23 +7,25 @@ import { NavControllerBase } from './nav-controller-base';
|
||||
import { Transition } from '../transitions/transition';
|
||||
|
||||
|
||||
export function getComponent(linker: DeepLinker, nameOrPageOrView: any): any {
|
||||
if (typeof nameOrPageOrView === 'function') {
|
||||
return nameOrPageOrView;
|
||||
}
|
||||
if (typeof nameOrPageOrView === 'string') {
|
||||
return linker.getComponentFromName(nameOrPageOrView);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function convertToView(linker: DeepLinker, nameOrPageOrView: any, params: any): ViewController {
|
||||
if (nameOrPageOrView) {
|
||||
if (isViewController(nameOrPageOrView)) {
|
||||
// is already a ViewController
|
||||
return nameOrPageOrView;
|
||||
}
|
||||
if (typeof nameOrPageOrView === 'function') {
|
||||
// is a page component, now turn it into a ViewController
|
||||
return new ViewController(nameOrPageOrView, params);
|
||||
}
|
||||
if (typeof nameOrPageOrView === 'string') {
|
||||
// is a string, see if it matches a
|
||||
const component = linker.getComponentFromName(nameOrPageOrView);
|
||||
if (component) {
|
||||
// found a page component in the link config by name
|
||||
return new ViewController(component, params);
|
||||
}
|
||||
let component = getComponent(linker, nameOrPageOrView);
|
||||
if (component) {
|
||||
return new ViewController(component, params);
|
||||
}
|
||||
}
|
||||
console.error(`invalid page component: ${nameOrPageOrView}`);
|
||||
@ -77,17 +79,17 @@ export function setZIndex(nav: NavControllerBase, enteringView: ViewController,
|
||||
}
|
||||
}
|
||||
|
||||
export function isTabs(nav: any) {
|
||||
export function isTabs(nav: any): boolean {
|
||||
// Tabs (ion-tabs)
|
||||
return !!nav && !!nav.getSelected;
|
||||
}
|
||||
|
||||
export function isTab(nav: any) {
|
||||
export function isTab(nav: any): boolean {
|
||||
// Tab (ion-tab)
|
||||
return !!nav && isPresent(nav._tabId);
|
||||
}
|
||||
|
||||
export function isNav(nav: any) {
|
||||
export function isNav(nav: any): boolean {
|
||||
// Nav (ion-nav), Tab (ion-tab), Portal (ion-portal)
|
||||
return !!nav && !!nav.push;
|
||||
}
|
||||
|
Reference in New Issue
Block a user