fix(app): navPop() does not go to previous tab

references #7611
This commit is contained in:
Manu Mtz.-Almeida
2016-12-03 21:40:45 +01:00
parent b63344c230
commit eebb062e71
3 changed files with 5 additions and 12 deletions

View File

@ -264,14 +264,7 @@ export class App {
if (nav) { if (nav) {
if (isTabs(nav)) { if (isTabs(nav)) {
// FYI, using "nav instanceof Tabs" throws a Promise runtime error for whatever reason, idk // FYI, using "nav instanceof Tabs" throws a Promise runtime error for whatever reason, idk
// this is a Tabs container // on tabs, we do nothing. see issue #7611
// see if there is a valid previous tab to go to
let prevTab = nav.previousTab(true);
if (prevTab) {
console.debug('app, goBack previous tab');
nav.select(prevTab);
return Promise.resolve();
}
} else if (isNav(nav) && nav.length() > 1) { } else if (isNav(nav) && nav.length() > 1) {
// this nav controller has more than one view // this nav controller has more than one view

View File

@ -9,7 +9,7 @@ describe('App', () => {
describe('goBack', () => { describe('goBack', () => {
it('should select the previous tab', () => { it('should not select the previous tab', () => {
let nav = mockNavController(); let nav = mockNavController();
app._setRootNav(nav); app._setRootNav(nav);
@ -31,11 +31,11 @@ describe('App', () => {
app.goBack(); app.goBack();
expect(tabs.select).toHaveBeenCalledWith(tab1); expect(tabs.select).not.toHaveBeenCalled();
expect(tab1.pop).not.toHaveBeenCalled(); expect(tab1.pop).not.toHaveBeenCalled();
expect(tab2.pop).not.toHaveBeenCalled(); expect(tab2.pop).not.toHaveBeenCalled();
expect(portal.pop).not.toHaveBeenCalled(); expect(portal.pop).not.toHaveBeenCalled();
expect(platform.exitApp).not.toHaveBeenCalled(); expect(platform.exitApp).toHaveBeenCalled();
}); });
it('should pop from the active tab, when tabs is nested is the root nav', () => { it('should pop from the active tab, when tabs is nested is the root nav', () => {

View File

@ -1,6 +1,6 @@
import { PanGesture } from './drag-gesture'; import { PanGesture } from './drag-gesture';
import { clamp, assert } from '../util/util'; import { clamp, assert } from '../util/util';
import { nativeRaf, pointerCoord } from '../util/dom'; import { pointerCoord } from '../util/dom';
/** /**
* @private * @private