Skip to content

Commit

Permalink
fix(router): fix issue 16710
Browse files Browse the repository at this point in the history
Fix issue 16710. Navigation events are called twice when using HashLocationStrategy. When user change url manually in browser URL.
ex: Router A(component A) using navigateByUrl(in guard) to redirect to Router B(Component B). When user enter router A in browser URL. That follow will be call twice. Detail in issue 16710

angular#16710
  • Loading branch information
congaptit committed Sep 28, 2019
1 parent 85990c3 commit 1f0562b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,10 @@ export class Router {
lastNavigation.rawUrl.toString() === rawUrl.toString()) {
return Promise.resolve(true); // return value is not used
}
// Fix issue 16710 (https://github.com/angular/angular/issues/16710)
if (source !== 'imperative' && this.location.path(true) !== rawUrl.toString()) {
return Promise.resolve(true); // return value is not used
}

let resolve: any = null;
let reject: any = null;
Expand Down

0 comments on commit 1f0562b

Please sign in to comment.