Skip to content

Commit 8b65398

Browse files
committed
fix(nav): view.id is not overridden
fixes #8794
1 parent 780717e commit 8b65398

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/navigation/nav-controller-base.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,10 @@ export class NavControllerBase extends Ion implements NavController {
689689
view._setNav(this);
690690

691691
// give this inserted view an ID
692-
view.id = this.id + '-' + (++this._ids);
692+
this._ids++;
693+
if (!view.id) {
694+
view.id = `${this.id}-${this._ids}`;
695+
}
693696

694697
// insert the entering view into the correct index in the stack
695698
this._views.splice(index, 0, view);

src/navigation/test/nav-controller.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ describe('NavController', () => {
165165

166166
describe('insert', () => {
167167

168+
it('should not modify the view id', () => {
169+
let view = mockView(MockView4);
170+
view.id = 'custom_id';
171+
nav.insert(0, view);
172+
173+
expect(view.id).toEqual('custom_id');
174+
});
175+
176+
168177
it('should insert at the begining with no async transition', () => {
169178
let view4 = mockView(MockView4);
170179
let instance4 = spyOnLifecycles(view4);

0 commit comments

Comments
 (0)