Skip to content

Commit

Permalink
fix(tabs): _touchActive() works when tab.root is a string
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Dec 6, 2016
1 parent 8efffff commit cb65f79
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/components/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
30 changes: 16 additions & 14 deletions src/navigation/nav-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit cb65f79

Please sign in to comment.