routerLinkActive does not updates on router.navigate to the same route
See original GitHub issueBug Report
Description
If we have some components that use router.navigate
for the same route but with empty object or null for queryParams
, then routerLinkActive
directive does mark links as active.
The use case to pass empty object is to pass some filters through query parameters to be able to share the link to the page.
Minimal Reproduction
https://stackblitz.com/edit/angular-ivy-brrc3a Here we have 2 components with service provided for each component. Service performs the navigation using:
this.router.navigate(['.'], {
queryParams: {},
relativeTo: this.route
});
After this any link will not be marked as active. If reload the page with preset url (ex: /one), then the link will be marked. But navigation to another route will not remove active state from the link.
Your Environment
Angular Version:
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1002.0
@angular-devkit/build-angular 0.1002.0
@angular-devkit/core 10.2.0
@angular-devkit/schematics 10.2.0
@angular/cdk 10.2.7
@angular/cli 10.2.0
@angular/material 10.2.7
@schematics/angular 10.2.0
@schematics/update 0.1002.0
rxjs 6.5.4
typescript 4.0.3
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
routerLinkActive does not work with router.navigateByUrl or ...
I'm running into the same issue. I do a lot of processing when a user clicks a link and so I didn't use...
Read more >RouterLinkActive - Angular
Tracks whether the linked route of an element is currently active, and allows you to specify one or more CSS classes to add...
Read more >Angular Router: A Complete Guide
We are going to learn how the Angular Router nested routes functionality can be used to build a Bootstrap menu navigation system, ...
Read more >Navigation • Angular - codecraft.tv
... how we can navigate between routes in Angular programmatically via the router ... The book and code has since been updated to...
Read more >Angular (10) – Routing | Jerry's Blog - GitHub Pages
In the path, DO NOT add the slash / . ... routerLinkActive attribute can be added at the <a> tag or <li> tag,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Airblader yep, pretty sure. The navigation from the service is triggered before the previous one completes.
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.