mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +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 { isBlank } from '../../util/util';
|
||||||
import { NavController } from '../../navigation/nav-controller';
|
import { NavController } from '../../navigation/nav-controller';
|
||||||
import { NavControllerBase } from '../../navigation/nav-controller-base';
|
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 { Platform } from '../../platform/platform';
|
||||||
import { Tab } from './tab';
|
import { Tab } from './tab';
|
||||||
import { TabHighlight } from './tab-highlight';
|
import { TabHighlight } from './tab-highlight';
|
||||||
@ -501,9 +501,9 @@ export class Tabs extends Ion implements AfterViewInit {
|
|||||||
|
|
||||||
} else if (tab.length() > 1) {
|
} else if (tab.length() > 1) {
|
||||||
// if we're a few pages deep, pop to root
|
// 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
|
// Otherwise, if the page we're on is not our real root, reset it to our
|
||||||
// default root type
|
// default root type
|
||||||
tab.setRoot(tab.root);
|
tab.setRoot(tab.root);
|
||||||
|
@ -7,23 +7,25 @@ import { NavControllerBase } from './nav-controller-base';
|
|||||||
import { Transition } from '../transitions/transition';
|
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 {
|
export function convertToView(linker: DeepLinker, nameOrPageOrView: any, params: any): ViewController {
|
||||||
if (nameOrPageOrView) {
|
if (nameOrPageOrView) {
|
||||||
if (isViewController(nameOrPageOrView)) {
|
if (isViewController(nameOrPageOrView)) {
|
||||||
// is already a ViewController
|
// is already a ViewController
|
||||||
return nameOrPageOrView;
|
return nameOrPageOrView;
|
||||||
}
|
}
|
||||||
if (typeof nameOrPageOrView === 'function') {
|
let component = getComponent(linker, nameOrPageOrView);
|
||||||
// is a page component, now turn it into a ViewController
|
if (component) {
|
||||||
return new ViewController(nameOrPageOrView, params);
|
return new ViewController(component, 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.error(`invalid page component: ${nameOrPageOrView}`);
|
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)
|
// Tabs (ion-tabs)
|
||||||
return !!nav && !!nav.getSelected;
|
return !!nav && !!nav.getSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isTab(nav: any) {
|
export function isTab(nav: any): boolean {
|
||||||
// Tab (ion-tab)
|
// Tab (ion-tab)
|
||||||
return !!nav && isPresent(nav._tabId);
|
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)
|
// Nav (ion-nav), Tab (ion-tab), Portal (ion-portal)
|
||||||
return !!nav && !!nav.push;
|
return !!nav && !!nav.push;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user