diff --git a/src/navigation/nav-controller-base.ts b/src/navigation/nav-controller-base.ts index 510772ff085..e20f82b42e1 100644 --- a/src/navigation/nav-controller-base.ts +++ b/src/navigation/nav-controller-base.ts @@ -689,7 +689,10 @@ export class NavControllerBase extends Ion implements NavController { view._setNav(this); // give this inserted view an ID - view.id = this.id + '-' + (++this._ids); + this._ids++; + if (!view.id) { + view.id = `${this.id}-${this._ids}`; + } // insert the entering view into the correct index in the stack this._views.splice(index, 0, view); diff --git a/src/navigation/test/nav-controller.spec.ts b/src/navigation/test/nav-controller.spec.ts index 206e0f6cf98..59d697f6f02 100644 --- a/src/navigation/test/nav-controller.spec.ts +++ b/src/navigation/test/nav-controller.spec.ts @@ -165,6 +165,15 @@ describe('NavController', () => { describe('insert', () => { + it('should not modify the view id', () => { + let view = mockView(MockView4); + view.id = 'custom_id'; + nav.insert(0, view); + + expect(view.id).toEqual('custom_id'); + }); + + it('should insert at the begining with no async transition', () => { let view4 = mockView(MockView4); let instance4 = spyOnLifecycles(view4);