selectSignal from Component store emits undefined when using NavigationActionTiming.PostActivation and .detectChanges() and lazy loading
Which @ngrx/* package(s) are the source of the bug?
component-store, router-store
Minimal reproduction of the bug/regression with instructions
Reproduction repo: https://github.com/yurakhomitsky/component-store-issue
Steps to reproduce:
- Clone the repo
- Run the application
- Open the console and navigate to the users page
a Component store with selectSignal emits undefined when the application has the following implemented:
- Lazy loads routes with a nested component that has ComponentStore in providers.
- When the application has router-store provided with
navigationActionTiming: NavigationActionTiming.PostActivation - When the application selects router state from the selector and calls
detectChanges()
With all of that, the application gets a runtime error when trying to access something from the Component store state
If you change navigationActionTiming to NavigationActionTiming.PostActivation - it works
If you change detectChanges to markForCheck - it works
Expected behavior
The selectSignal method from the component store should not emit undefined if the application has the code written mentioned above
Component store does not emit undefined if using the select method that returns Observable
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)
NgRx: "@ngrx/component-store": "^19.1.0", "@ngrx/router-store": "^19.1.0", "@ngrx/store": "^19.1.0",
Angular: "@angular/core": "^19.2.0",
Other information
No response
I would be willing to submit a PR to fix this issue
- Yes
- No
Source: ngrx/platform