mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(tabs): popToRoot catches the rejected promise
This commit is contained in:
@@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
|
||||
@@ -315,6 +315,11 @@ export class Tab2Page3 {
|
||||
|
||||
constructor(public navCtrl: NavController) {}
|
||||
|
||||
ionViewCanLeave() {
|
||||
console.log('Tab2Page3, ionViewCanLeave', false);
|
||||
return false;
|
||||
}
|
||||
|
||||
ionViewWillEnter() {
|
||||
console.log('Tab2Page3, ionViewWillEnter');
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user