You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Router links in @defer blocks not having correct relative route #54864
Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
17.2.1
Description
A RouterLink with a route of ./ should route to the activated route. (eg. <a [routerLink]="'./'" >Link One</a>). But when it is in a defer block, and it is a sibling of a component that imports from material it routes to the app root.
So @defer(on timer(1000)) { <has-material/> <a [routerLink]="'./'" >Link One</a> } routes to the root.
Hello, it seems that I have the same problem there, I wanted to use defer blocks to load a different layout depending on the result of the BreakpointObserver, both having a router outlet for child pages.
The problem occur with a component from Angular Material, it seems that the router and ActivatedRoute are not "synchronized" anymore.
This bug seems like the previous bug. Using a defer block around a component that imports 'something' causes issues with the ActivatedRoute in that component.
@Yberion@bboyle thanks for providing a repro. We've identified the root cause and I've created a PR with a fix: #55374. I will update this thread once the mentioned PR lands.
Activity
crisbeto commentedon Mar 14, 2024
This seems like either a framework or router issue. Material doesn't use the router at all. Transferring to the framework repo.
alxhub commentedon Mar 14, 2024
Likely related to the injector construction of
@defer.JeanMeche commentedon Mar 14, 2024
I could narrow it down a bit:
The
ActivatedRoutehas an undefined route when in a defer block and having a import (whatever import).repro: https://stackblitz.com/edit/angular-repro-54864
29 remaining items
Yberion commentedon Apr 16, 2024
Hello, it seems that I have the same problem there, I wanted to use defer blocks to load a different layout depending on the result of the
BreakpointObserver, both having a router outlet for child pages.The problem occur with a component from
Angular Material, it seems that the router andActivatedRouteare not "synchronized" anymore.npm inpm run startgo to page1 from homepage2page 1homepage2homeAnd it is at this point that we get different results from the router and the snapshot.
The problem appears in the component that is defered
LoaderComponent, no problem in theSomepageComponent(check console logs).The problem disappears if I remove
MatButtonModulefromLoaderComponentOR if I remove the defer block fromSomepageComponent.I'm on Angular
17.3.4NachmanBerkowitz commentedon Apr 16, 2024
This bug seems like the previous bug. Using a defer block around a component that imports 'something' causes issues with the ActivatedRoute in that component.
AndrewKushnir commentedon Apr 17, 2024
@Yberion @bboyle thanks for providing a repro. We've identified the root cause and I've created a PR with a fix: #55374. I will update this thread once the mentioned PR lands.
fix(core): make `ActivatedRoute` inject correct instance inside `@def…
fix(core): make `ActivatedRoute` inject correct instance inside `@def…
fix(core): make `ActivatedRoute` inject correct instance inside `@def…
AndrewKushnir commentedon Apr 25, 2024
FYI, the fix from PR #55374 was merged and released as a part of v17.3.6. Please let us know if the problem still exists after updating to v17.3.6.
Yberion commentedon Apr 25, 2024
Hello @AndrewKushnir, thanks a lot for the fix. I can confirm on my side that it is working now!
angular-automatic-lock-bot commentedon May 26, 2024
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.