-
Notifications
You must be signed in to change notification settings - Fork 25.5k
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
Router CanDeactivate runs twice when back button is pressed #11754
Comments
Having the exact same issue for the CanActivate guards. Manually changing the url or pressing back/forward browser history buttons is triggering the guard twice. I'm using the LocationHashStrategy. |
If anybody needs workaround follow this steps:
|
@ErikGrijzen I have the same problem. It is already fixed for you? |
Had the same problem and realized it was because i was return a promise. I changed it to an observable and it was fixed... |
I have similiar issue, but CanDeactivate is called twice when I am using links (second modal appear after closing first one). When I use router.navigate method canDeactivate it's called only once. Returning observable instead of promise does not fix it. Does anybody have workaround for that? my canDeactivate method:
I am using Angular Router 6.1.4 @kemsky Could you provide us your workaround. I don't understand your explanation. Thanks. |
I am having the same issue, were you able to resolve this? |
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. |
I'm submitting a ... (check one with "x")
Current behavior
CanDeactivate
guard runs twice if i use browser back button andcanDeactivate
returns promise or observable (any delayed result). If i return true/false it will execute once. If i use links to navigate it also work fine.The problem is that i can't create plunker :(
Relevant logs:
It looks like navigation was fired twice.
Expected behavior
Should be executed once and wait for result.
Reproduction of the problem
What is the motivation / use case for changing the behavior?
It results in two confirm dialogs. I would really appreciate solution to this.
The text was updated successfully, but these errors were encountered: