mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(navcontrollerbase): popToRoot should not remove root view
This commit is contained in:
@ -331,7 +331,7 @@ export class NavControllerBase extends Ion implements NavController {
|
|||||||
if (ti.removeCount < 0) {
|
if (ti.removeCount < 0) {
|
||||||
ti.removeCount = (viewsLength - ti.removeStart);
|
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) {
|
if (ti.insertViews) {
|
||||||
|
@ -622,6 +622,25 @@ describe('NavController', () => {
|
|||||||
});
|
});
|
||||||
}, 10000);
|
}, 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', () => {
|
describe('remove', () => {
|
||||||
|
Reference in New Issue
Block a user