Skip to content

Commit

Permalink
fix(navcontrollerbase): popToRoot should not remove root view
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasGassmann authored and manucorporat committed May 4, 2017
1 parent 7aa07b0 commit 646d736
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/navigation/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 19 additions & 0 deletions src/navigation/test/nav-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 646d736

Please sign in to comment.