Repository navigation
Closed
Labels
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
After upgrading to RC2, links under defer blocks with control statement e.g. @if now takes 2 clicks to navigate
For the below code its now taking two clicks for the actual navigation to complete.
The first click hydrates this code and removes ngb="d9" attribute from the anchor tag and then clicking it again actully takes the user to the next page.
@defer(on idle; hydrate on interaction) {
<div class="mat-chip-list layout-row layout-wrap layoutalign-center-center pl10 pr10 mb20">
@for (item of topCities(); track item.name; let index = $index) {
<a [routerLink]="['/jobs/',urlCountry(),item.url]" class="mat-chip">Jobs in {{item.name}}</a>
}
@if (telecommute()) {
<a [routerLink]="['/jobs/',urlCountry(),'online']" class="mat-chip">Online Jobs</a>
}
<a [routerLink]="['/jobs/',urlCountry()]" title="Jobs in {{country()}}" class="mat-chip">Jobs in {{_gs.country()}}</a>
</div>
}
On the otherhand the below code seems to be working as expected:
@defer(on idle; prefetch on immediate; hydrate on interaction) {
<div class="text-center mt30 mb30 pt5 pb5">
<a ripple [routerLink]="isBrowser() ? null : '/account/register'" (click)="login('/account/dashboard')" rel="nofollow" class="signup-button">Start Your Job Search – Join Now!</a>
</div>
}
You can try this on the reproduction repo I shared below.
- Clone the repo
- Run
ng serve - Click any link from the top nav and you will notice that the first click hydrates the component and then the second click actully take you to the next page
If you remove the if condition (https://github.com/naveedahmed1/incremental-hydration-demo/blob/54f41384ec5aa01e70ab2127f1b83015580185d1/src/app/app.component.html#L5) it will work just fine.
Please provide a link to a minimal reproduction of the bug
Please provide the exception or error you saw
Links under defer blocks with control statement e.g. @if takes 2 clicks to navigate
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 19.0.0-rc.2
Node: 20.12.2
Package Manager: npm 10.6.0
OS: win32 x64
Angular: 19.0.0-rc.2
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1900.0-rc.2
@angular-devkit/build-angular 19.0.0-rc.2
@angular-devkit/core 19.0.0-rc.2
@angular-devkit/schematics 19.0.0-rc.2
@schematics/angular 19.0.0-rc.2
rxjs 7.8.1
typescript 5.6.3
zone.js 0.15.0
Anything else?
No response
Activity
naveedahmed1 commentedon Nov 15, 2024
cc @thePunderWoman
thePunderWoman commentedon Nov 15, 2024
@naveedahmed1 I've replicated this. It affects routerLinks constructed via arrays or if using data from the parent component.
naveedahmed1 commentedon Nov 16, 2024
Are you sure? For the below code, the first Login link is taking two clicks whereas the second login link is working just fine:
and even
routerLinkwith array is also working fine if I move it outide of theifblock i.e:thePunderWoman commentedon Nov 18, 2024
@naveedahmed1 It's really any routerLink that's not a pure string. We're working on it.
fix(core): Prevents race condition of cleanup for incremental hydrati…
angular-automatic-lock-bot commentedon Dec 22, 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.