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
Navigation events are called twice when using HashLocationStrategy #16710
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
When using HashLocationStrategy and change url manually to the one, which is protected by CanActivate guard (this returns false and fire redirect to the other page), navigation events are called twice.
Expected behavior
All navigation event are called once only.
Minimal reproduction of the problem with instructions
Use the demo in http://plnkr.co/edit/4xlYD9wmetG5G0Dvjp0E?p=preview
Open window mode http://run.plnkr.co/plunks/4xlYD9wmetG5G0Dvjp0E/#/component-one
Click Guarded Component Two link - only one NavigationStart and NavigationCancel events logged in console.
Manually change url from /#/component-one to /#/component-two and hit enter - two pair of NavigationStart and NavigationCancel events logged in console.
What is the motivation / use case for changing the behavior?
As the duplication of navigation event causes guards logic to be executed twice (and this may contain API calls) - it is a performance issue. Potentially, if guard resolving depends on some conditions which are true after first failed attempt - the second one will be successful, however it is not desired behavior.
Same here with Angular 5.
Any update on this?
I pretty sure this issue is braking the back button click in the browser getting A->B->C and looping between B and C with the back button click in browser.
Activity
IAMtheIAM commentedon Oct 12, 2017
No activity or solution in months? This bug still exists. @jasonhodges Is this still on Angulars radar? Its a significant bug, in my opinion.
Duplicate issue at #18366
lifenautjoe commentedon Jan 29, 2018
Getting five NavigationEnd events fired when
blackrek commentedon Feb 12, 2018
have same problem.
i planning update to 5 version, maybe this will help
IraErshova commentedon Feb 23, 2018
Have the same problem. Use Angular version: 5.2.2 and Typescript 2.6.2
aerlijman commentedon Apr 3, 2018
Same here with Angular 5.
Any update on this?
I pretty sure this issue is braking the back button click in the browser getting A->B->C and looping between B and C with the back button click in browser.
harlenalvarez commentedon Apr 5, 2018
I have the same problem. Angular version 5.2.9
Dhamu143 commentedon Apr 10, 2018
is there any update ??
padilla-jm commentedon Apr 13, 2018
I am able to work around this issue but I am also very interested in a fix.
rinkeshmistry commentedon Apr 24, 2018
@jfox459 can u please provide your work around ?
58 remaining items
fix(router): fix navigation ignoring logic to compare to the browser …
angular-automatic-lock-bot commentedon Aug 13, 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.
fix(router): ensure duplicate popstate/hashchange events are handled …