fix(tabs): select returns boolean

This commit is contained in:
Manu Mtz.-Almeida
2018-02-16 18:22:14 +01:00
parent ca2ef5eac0
commit 893c9a54d2
2 changed files with 13 additions and 12 deletions

View File

@ -1365,13 +1365,13 @@ export function updateTab(nav: Nav, component: any, data: any, escapeHatch: Esca
// yeah yeah, I know this is kind of ugly but oh well, I know the internal structure of <ion-tabs> // yeah yeah, I know this is kind of ugly but oh well, I know the internal structure of <ion-tabs>
const tabs = tab.parentElement.parentElement as HTMLIonTabsElement; const tabs = tab.parentElement.parentElement as HTMLIonTabsElement;
return isTabSelected(tabs, tab).then((isSelected: boolean) => { return isTabSelected(tabs, tab).then((isSelected) => {
if (!isSelected) { if (!isSelected) {
const promise = updateNav(nav, component, data, escapeHatch, isTopLevel); const promise = updateNav(nav, component, data, escapeHatch, isTopLevel);
const app = document.querySelector('ion-app'); const app = document.querySelector('ion-app');
return app.componentOnReady().then(() => { return app.componentOnReady().then(() => {
app.setExternalNavPromise(promise); app.setExternalNavPromise(promise);
}).then(() => {
// okay, the tab is not selected, so we need to do a "switch" transition // okay, the tab is not selected, so we need to do a "switch" transition
// basically, we should update the nav, and then swap the tabs // basically, we should update the nav, and then swap the tabs
return promise.then((navResult) => { return promise.then((navResult) => {

View File

@ -122,11 +122,12 @@ export class Tabs implements NavOutlet {
const leavingTab = this.selectedTab; const leavingTab = this.selectedTab;
return selectedTab.setActive() return selectedTab.setActive().then(() => {
.then(() => {
selectedTab.selected = true; selectedTab.selected = true;
if (leavingTab && leavingTab !== selectedTab) { if (leavingTab !== selectedTab) {
if (leavingTab) {
leavingTab.active = false; leavingTab.active = false;
}
this.selectedTab = selectedTab; this.selectedTab = selectedTab;
this.ionChange.emit(selectedTab); this.ionChange.emit(selectedTab);
this.ionNavChanged.emit({isPop: false}); this.ionNavChanged.emit({isPop: false});