question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[angular 9] child pages initially added to incorrect container element in Ionic Angular apps

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package @angular/routing

Is this a regression?

Yes, the previous version in which this bug was not present was: Angular 8.x

Description

We are running into an issue with navigation on Angular 9. It seems that after the upgrade, Angular is inserting pages into the wrong container component. We have the following DOM layout:

app-root (the main component for the Angular app)
|
|_____ion-app (a web component that manages Ionic utilities)
|     |
|_____|_____ion-router-outlet (a web component that is a wrapper around Angular's router outlet)
|     |     |
|_____|_____|_____app-home (the main page of our application)

Clicking a button in app-home navigates you to app-child. In Angular <=8, this child page is added as a child inside of ion-router-outlet. With Angular 9, this page is initially added as child of ion-app, and then re-added as a child of ion-router-outlet . This is causing issues with our users’ apps as certain components no longer work on subsequent navigations to the child page.

πŸ”¬ Minimal Reproduction

Angular 8 repro: https://github.com/liamdebeasi/ng8-routing-repro Angular 9 repro: https://github.com/liamdebeasi/ng9-routing-repro

Please see repo README files for steps to reproduce.

🌍 Your Environment

Angular Version:


Angular CLI: 9.0.1
Node: 10.15.0
OS: darwin x64

Angular: 9.0.0
... common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.801.3
@angular-devkit/build-angular     0.900.1
@angular-devkit/build-optimizer   0.900.1
@angular-devkit/build-webpack     0.900.1
@angular-devkit/core              9.0.1
@angular-devkit/schematics        9.0.1
@angular/cli                      9.0.1
@ngtools/webpack                  9.0.1
@schematics/angular               8.1.3
@schematics/update                0.900.1
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Anything else relevant?

This is an Ionic Framework v5 application, but we have not changed anything related to our routing setup with regards to Angular 9.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
atscottcommented, Feb 12, 2020

Yes, this is related to the last bullet point in the breaking changes:

Embedded views (such as ones created by *ngFor) are now inserted in front of anchor DOM comment node (e.g. ) rather than behind it as was the case previously. In most cases this does not have any impact on rendered DOM. In some cases (such as animations delaying the removal of an embedded view) any new embedded views will be inserted after the embedded view being animated away. This difference only last while the animation is active, and might alter the visual appearance of the animation. Once the animation is finished the resulting rendered DOM is identical to that rendered with View Engine.

It has to do with the indexes of the ViewContainerRef and how it determines siblings. https://github.com/ionic-team/ionic/blob/master/angular/src/directives/navigation/ion-router-outlet.ts#L201. But essentially if you’re moving nodes around yourself, it could coincidentally work with a current implementation and then break if we change how we track nodes.

0reactions
angular-automatic-lock-bot[bot]commented, Mar 14, 2020

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ViewChild
Property decorator that configures a view query. The change detector looks for the first element or the directive matching the selector in the...
Read more >
How To Use the ng-container Element in Angular
In this article, you explored the problems that ng-container addresses in your Angular applications, like redundant elements and invalid HTMLΒ ...
Read more >
ViewChild in *ngIf - angular
My solution was to extract the div and ViewChild into it's own child component which when used in the parent component was able...
Read more >
Angular Router: Child Routes, Auxiliary Routes, Master Detail
In the ancient strategy the URL was pointing to the root of the domain, so when hitting refresh this would reload index.html ,...
Read more >
UI Components & API Customization to Create Interface
Ionic apps are made of high-level building blocks called UI components. Demo Ionic Framework API customization and quickly create your app interface.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found