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
Repeated navigation attempts not possible when canDeactivate guard turns down initial navigation and urlUpdateStrategy set to "eager" #28561
Yes, the previous version in which this bug was not present was: 7.2.0
Description
NB! I'm running with the Router's urlUpdateStrategy set to "eager".
I have a modal outlet, in which the routes have a canDeactivate guard preventing the user from closing the modal when there is pending changes. Until version 7.2.1, the user would be able to attempt to close the modal as many times as they wanted, triggering the guard every time. In version 7.2.1 and onwards, the guard is triggered the first time, but not on subsequent navigation attempts.
As far as I can see, this unexpected behavior is due to 6ae7aee. It seems like the following change is a bit aggressive:
If you debug the above mentioned code in the reproduction, you'll see that the browserUrlTree is updated before the guard runs, and the changes aren't being undone when the guard denies navigation. This behavior will cause subsequent attempts to close the modal to stop at the following check:
This is happening because the Router fails to reset the browserUrlTree when a navigation is rejected. This is resolved in the (currently private option) canceledNavigationResolution: 'computed'.
Activity
jasonaden commentedon May 14, 2019
This should be fixed with a PR landing shortly: #30344
Please let me know if this fixes it, and close this issue if so.
larrifax commentedon Jun 5, 2019
@jasonaden The bug is still present in
8.1.0-beta.0, which seems to be the first release in which #30344 is included.I've updated the repro to
8.1.0-beta.0(https://stackblitz.com/edit/angular-issue-repro2-yq1jm2).FDIM commentedon Oct 25, 2019
I've just bumped into this issue - Looks like it is still present in 8.2.9 and based on changelog probably in 8.2.12 as well
atscott commentedon Jan 13, 2021
Additional reproduction due to dueling
routerLinknavigations: https://stackblitz.com/edit/angular-ivy-db9ngv?file=src%2Fapp%2Fapp-routing.module.ts (routerLinkis applied to both the wrapper and the inner anchor, causing duplicate navigation attempts)atscott commentedon Aug 10, 2021
This is happening because the Router fails to reset the
browserUrlTreewhen a navigation is rejected. This is resolved in the (currently private option)canceledNavigationResolution: 'computed'.Demo: https://stackblitz.com/edit/angular-issue-repro2-qzg9nn?file=src%2Fapp%2Fapp.component.ts
atscott commentedon Sep 8, 2021
Closing as resolved by
canceledNavigationResolution: 'computed'which will be available in v13angular-automatic-lock-bot commentedon Oct 9, 2021
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.