Skip to content

Commit

Permalink
fix(tabs): popToRoot catches the rejected promise
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Feb 28, 2017
1 parent 8d9f374 commit 7385158
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/components/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,16 @@ export class Tabs extends Ion implements AfterViewInit {

} else if (tab.length() > 1) {
// if we're a few pages deep, pop to root
tab.popToRoot();
tab.popToRoot().catch(() => {
console.debug('Tabs: pop to root was cancelled');
});

} 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);
tab.setRoot(tab.root).catch(() => {
console.debug('Tabs: reset root was cancelled');
});
}
}
}
Expand All @@ -545,7 +549,7 @@ export class Tabs extends Ion implements AfterViewInit {
*/
setTabbarPosition(top: number, bottom: number) {
if (this._top !== top || this._bottom !== bottom) {
const tabbarEle = <HTMLElement>this._tabbar.nativeElement;
var tabbarEle = <HTMLElement>this._tabbar.nativeElement;
tabbarEle.style.top = (top > -1 ? top + 'px' : '');
tabbarEle.style.bottom = (bottom > -1 ? bottom + 'px' : '');
tabbarEle.classList.add('show-tabbar');
Expand Down
5 changes: 5 additions & 0 deletions src/components/tabs/test/advanced/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ export class Tab2Page3 {

constructor(public navCtrl: NavController) {}

ionViewCanLeave() {
console.log('Tab2Page3, ionViewCanLeave', false);
return false;
}

ionViewWillEnter() {
console.log('Tab2Page3, ionViewWillEnter');
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/tabs/test/advanced/tab2page3.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
<h2>Tab 2, Page 3</h2>

<p>No Header.</p>
<p>This page can't be left</p>

<p><button ion-button (click)="navCtrl.pop()">Back to Tab 2, Page 2</button></p>
<p><button ion-button navPop>Back to Tab 2, Page 2</button></p>
<div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div>
<div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div>

Expand Down

0 comments on commit 7385158

Please sign in to comment.