New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returning UrlTree from CanActivate guard breaks browser's history and leads to an inconsistent state #43101
Labels
area: router
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
router: guards/resolvers
router: navigation pipe
events/scheduleNavigation/transitions observable
Milestone
Comments
atscott
added
area: router
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
router: guards/resolvers
router: navigation pipe
events/scheduleNavigation/transitions observable
labels
Aug 10, 2021
atscott
added a commit
to atscott/angular
that referenced
this issue
Aug 10, 2021
…ations The management of `browserUrlTree` currently has several problems with correctly tracking the actual state of the browser. This change makes the Router eagerly update the `browserUrlTree` when handling navigations triggered by browser events (i.e., not 'imperative'). This is becauses with those types of navigations, the browser URL bar is _already_ updated. If we do not update the internal tracking of the `browserUrlTree`, we will be out of sync with the real URL if the navigation is rejected. It would be best if we could remove `browserUrlTree` completely, but doing that would require a lot more investigation and is blocked by angular#27059 because the SpyLocation used in tests does not emulate real browser behavior. fixes angular#43101
atscott
added a commit
to atscott/angular
that referenced
this issue
Aug 10, 2021
…ations The management of `browserUrlTree` currently has several problems with correctly tracking the actual state of the browser. This change makes the Router eagerly update the `browserUrlTree` when handling navigations triggered by browser events (i.e., not 'imperative'). This is because with those types of navigations, the browser URL bar is _already_ updated. If we do not update the internal tracking of the `browserUrlTree`, we will be out of sync with the real URL if the navigation is rejected. It would be best if we could remove `browserUrlTree` completely, but doing that would require a lot more investigation and is blocked by angular#27059 because the SpyLocation used in tests does not emulate real browser behavior. fixes angular#43101
dylhunn
pushed a commit
that referenced
this issue
Aug 16, 2021
…ations (#43102) The management of `browserUrlTree` currently has several problems with correctly tracking the actual state of the browser. This change makes the Router eagerly update the `browserUrlTree` when handling navigations triggered by browser events (i.e., not 'imperative'). This is because with those types of navigations, the browser URL bar is _already_ updated. If we do not update the internal tracking of the `browserUrlTree`, we will be out of sync with the real URL if the navigation is rejected. It would be best if we could remove `browserUrlTree` completely, but doing that would require a lot more investigation and is blocked by #27059 because the SpyLocation used in tests does not emulate real browser behavior. fixes #43101 PR Close #43102
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
TeriGlover
pushed a commit
to TeriGlover/angular
that referenced
this issue
Sep 16, 2021
…ations (angular#43102) The management of `browserUrlTree` currently has several problems with correctly tracking the actual state of the browser. This change makes the Router eagerly update the `browserUrlTree` when handling navigations triggered by browser events (i.e., not 'imperative'). This is because with those types of navigations, the browser URL bar is _already_ updated. If we do not update the internal tracking of the `browserUrlTree`, we will be out of sync with the real URL if the navigation is rejected. It would be best if we could remove `browserUrlTree` completely, but doing that would require a lot more investigation and is blocked by angular#27059 because the SpyLocation used in tests does not emulate real browser behavior. fixes angular#43101 PR Close angular#43102
TeriGlover
pushed a commit
to TeriGlover/angular
that referenced
this issue
Sep 22, 2021
…ations (angular#43102) The management of `browserUrlTree` currently has several problems with correctly tracking the actual state of the browser. This change makes the Router eagerly update the `browserUrlTree` when handling navigations triggered by browser events (i.e., not 'imperative'). This is because with those types of navigations, the browser URL bar is _already_ updated. If we do not update the internal tracking of the `browserUrlTree`, we will be out of sync with the real URL if the navigation is rejected. It would be best if we could remove `browserUrlTree` completely, but doing that would require a lot more investigation and is blocked by angular#27059 because the SpyLocation used in tests does not emulate real browser behavior. fixes angular#43101 PR Close angular#43102
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area: router
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
router: guards/resolvers
router: navigation pipe
events/scheduleNavigation/transitions observable
Which @angular/* package(s) are the source of the bug?
router
Is this a regression?
No
Description
Returning a
UrlTree
fromCanActivate
guard should return in cancelling current navigation and redirecting to a new one.The following events result in an inconsistent state:
CanActivate
guard now returns aUrlTree
to a valid routePlease provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/angular-router-issue?file=src/app/app.component.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in
Anything else?
Demo of the issue:
The text was updated successfully, but these errors were encountered: