The canDeactivate guard is called with a null component

🐞 bug report

Is this a regression?

Yes

Description

The canDeactivate guard is called with a null component

🔬 Minimal Reproduction

https://stackblitz.com/edit/injected-component-in-the-candeactivate-guard-is-null?file=src%%2Fapp%%2Fapp.module.ts

🌍 Your Environment

Angular Version:
11.0.8 (but not specific to this version, I can reproduce it in other versions)

1 possible answer(s) on “The canDeactivate guard is called with a null component

  1. Closing as working as expected. There’s no router-outlet in the application so there is also no activated component. In this case null makes sense. We tried introducing a warning message for this case, but it’s a very common scenario in tests, see #38804 (comment).