-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
canDeactivate() is triggered twice #45
Comments
Hmmm. That is an interesting problem. I'll need to think a bit about it. |
I also have the canDeactivate function exectued twice but i don't have a canActivate in the next route. When this problem happens, the deactivate function doesn't get triggered aldough the page is navigated away from. note: ok seems the detached() was called instead. Which is a bit strange, because it's not an attribute or custom element. It's a base class which is overriden. In some/most situations it calls deactivate. In some it calls detached. I don't know why but cleanup works now. |
What is the desired behavior here? If |
I believe that I just ran into this as well. canDeactivate is triggered, then there is a redirect, and then canDeactivate is triggered again. Like @flieks, there is no canActivate for me either, so it has nothing to do with that. This has been a bug for over 2 years. I think the suggestion by @davismj is the way to go: prevent multiple calls to the same canDeactivate() per activation cycle. |
the same issue |
To handle this, I've added a new parameter to the router called `couldDeactivate` which is set to true whenever the CanDeactivatePreviousStep completes and is reset on every navigation. If a redirect is returned from the CanActivateNextStep, then this value will be true and it is used to build a special pipeline that skips the CanDeactivatePreviousStep on the next pipeline run. fixes #45
Are we back-porting all of this to the TS conversion, so that we don't have a regression? |
Gunna update the TS conversion PR with changes here. |
canDeactivate() is triggered twice when you navigate to another route where canActivate returns new Redirect('...').
Is there any workaround?
The text was updated successfully, but these errors were encountered: