Skip to content
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

Component Destruction Occurs Before canDeactivate Guard : Component is destory before going to canDeactivate guard. #55867

Closed
usmanmanii opened this issue May 18, 2024 · 1 comment

Comments

@usmanmanii
Copy link

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

Yes

Description

I’m attempting to add an unsaved popup modal in my component. I’ve used lazy loading to load modules, and after that, I’m loading standalone components. However, I’ve encountered an issue: when applying a canDeactivate Guard, the canDeactivateFn loses the component reference. As a result, the component is destroyed before the canDeactivate Guard is called with a null component value. Is there any way to handle this? I’ve tried various approaches.

i'm using "@angular/router": "^17.0.7",

image

image
image

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.0.8
Node: 20.10.0
Package Manager: npm 10.2.3
OS: win32 x64

Angular: 17.0.8
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic
... platform-server, router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.8
@angular-devkit/build-angular   17.0.8
@angular-devkit/core            17.0.8
@angular-devkit/schematics      17.0.8
@angular/cdk                    17.0.5
@angular/google-maps            17.1.0
@schematics/angular             17.0.8
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Anything else?

No response

@atscott
Copy link
Contributor

atscott commented May 18, 2024

I’m going to close this as a support request since there’s no reproduction and the router does not destroy components until guards and resolvers have completed so there must be something else going on here.

This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag angular.

If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation.

@atscott atscott closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants