fix(navcontrollerbase): popToRoot should not remove root view

This commit is contained in:
AndreasGassmann
2017-05-03 19:15:23 +02:00
committed by Manu MA
parent 7aa07b05ee
commit 646d736d07
2 changed files with 20 additions and 1 deletions

View File

@ -331,7 +331,7 @@ export class NavControllerBase extends Ion implements NavController {
if (ti.removeCount < 0) {
ti.removeCount = (viewsLength - ti.removeStart);
}
ti.leavingRequiresTransition = ((ti.removeStart + ti.removeCount) === viewsLength);
ti.leavingRequiresTransition = (ti.removeCount > 0) && ((ti.removeStart + ti.removeCount) === viewsLength);
}
if (ti.insertViews) {

View File

@ -622,6 +622,25 @@ describe('NavController', () => {
});
}, 10000);
it('should not pop first view if it\'s the only view', (done: Function) => {
let view1 = mockView(MockView1);
mockViews(nav, [view1]);
nav.popToRoot(null, trnsDone).then(() => {
let hasCompleted = true;
let requiresTransition = false;
expect(trnsDone).toHaveBeenCalledWith(
hasCompleted, requiresTransition, undefined, undefined, undefined
);
expect(nav.length()).toEqual(1);
expect(nav.getByIndex(0).component).toEqual(MockView1);
done();
}).catch((err: Error) => {
fail(err);
done(err);
});
}, 10000);
});
describe('remove', () => {