fix(router): redirect to root url when returned as UrlTree from guard (#28271)
When a UrlTree of root url was returned by a guard as a redirection, the navigation was not processed. The issue came from the error handler which incorrectly marked the router as already navigated. Fixes #27845 PR Close #28271
This commit is contained in:
@ -715,9 +715,14 @@ export class Router {
|
||||
/* This error type is issued during Redirect, and is handled as a cancellation
|
||||
* rather than an error. */
|
||||
if (isNavigationCancelingError(e)) {
|
||||
this.navigated = true;
|
||||
const redirecting = isUrlTree(e.url);
|
||||
if (!redirecting) {
|
||||
// Set property only if we're not redirecting. If we landed on a page and
|
||||
// redirect to `/` route, the new navigation is going to see the `/` isn't
|
||||
// a change from the default currentUrlTree and won't navigate. This is
|
||||
// only applicable with initial navigation, so setting `navigated` only when
|
||||
// not redirecting resolves this scenario.
|
||||
this.navigated = true;
|
||||
this.resetStateAndUrl(t.currentRouterState, t.currentUrlTree, t.rawUrl);
|
||||
}
|
||||
const navCancel =
|
||||
|
Reference in New Issue
Block a user