Skip to content

fix(router): set currentNavigation.targetRouterState after loading components and resources - #72350

Open
atscott wants to merge 1 commit into
angular:mainfrom
atscott:router-target-router-state-after-resources
Open

atscott wants to merge 1 commit into
angular:mainfrom
atscott:router-target-router-state-after-resources

Conversation

@atscott

@atscott atscott commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Moves the currentNavigation().targetRouterState update in NavigationTransitions.setupNavigations() from the createRouterState step to right after loadComponents and setupAndRunResources complete (right before afterPreactivation()), for both 3p and g3.

Prior to route resources (in 1f287b9ba7), targetRouterState was set after loadComponents finished right before afterPreactivation(), and StateManager only reads it at BeforeActivateRoutes / NavigationCancel(Redirect). Because currentNavigation is created with {equal: () => false}, updating it earlier emitted a signal notification and exposed targetRouterState before components and blocking route resources finished loading.

Also updates the rxResource integration test in router_resource_spec.ts to inspect the resource loading state directly instead of reading @internal currentNavigation().targetRouterState while the resource is still loading, and asserts targetRouterState stays unset until resources complete.

…mponents and resources

Previously, `NavigationTransitions.setupNavigations()` updated
`currentNavigation().targetRouterState` inside the `createRouterState`
step before `loadComponents()` and `setupAndRunResources()` ran. Because
`currentNavigation` uses `{equal: () => false}`, that triggered a signal
notification and exposed `targetRouterState` before component loading and
blocking route resources had settled. Prior to route resources (in
`1f287b9ba7`), `targetRouterState` was only assigned after `loadComponents()`
finished right before `afterPreactivation()`, and `StateManager` only reads
it at `BeforeActivateRoutes` / `NavigationCancel(Redirect)`.

Move the `this.currentNavigation.update(...)` assignment into a `tap` after
the `loadComponents` / `setupAndRunResources` stage (right before
`afterPreactivation()`) for both 3p and g3, and update the `rxResource`
integration test to inspect the resource's loading state directly while
asserting `currentNavigation().targetRouterState` remains unset until
resources complete.
@atscott atscott changed the title refactor(router): set currentNavigation.targetRouterState after loading components and resources fix(router): set currentNavigation.targetRouterState after loading components and resources Dec 4, 2026
@atscott
atscott force-pushed the router-target-router-state-after-resources branch from cc4f881 to 146b801 Compare December 4, 2026 17:47
@atscott
atscott requested a review from JeanMeche December 4, 2026 18:05
@atscott atscott added target: minor This PR is targeted for the next minor release requires: TGP This PR requires a passing TGP before merging is allowed labels Dec 4, 2026
@atscott
atscott marked this pull request as ready for review December 4, 2026 18:05
@JeanMeche

JeanMeche commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Nit: Why target minor if this is a fix ?
Does it rely on code only on main ?

@atscott

atscott commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Nit: Why target minor if this is a fix ?

I think so this has to do with code that's moved around a lot recently and has g3 patches

@atscott

atscott commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

If we wanted it in patch, I would likely have to do a separate PR and resolve conflicts

@atscott

atscott commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

@atscott atscott added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release and removed target: minor This PR is targeted for the next minor release labels Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: router requires: TGP This PR requires a passing TGP before merging is allowed target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants