Skip to content

Conversation

@dimakuba
Copy link
Contributor

@dimakuba dimakuba commented Jul 7, 2025

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

This PR addresses an issue where preloaded components are not being activated as expected when preloading is enabled. In certain scenarios, the preloading strategy loads the component, but the route activation does not occur, resulting in the component not being displayed to the user.

What is the new behavior?

This change aims to ensure that preloaded components are properly activated after being loaded.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Please review this simplified example, which demonstrates the issue. In our production application, we encountered this problem in a more complex scenario: https://stackblitz.com/edit/stackblitz-starters-u44n3ca2?file=package.json

@pullapprove pullapprove bot requested a review from devversion July 7, 2025 15:48
@ngbot ngbot bot added this to the Backlog milestone Jul 7, 2025
@devversion devversion requested review from atscott and removed request for devversion July 7, 2025 17:28
Copy link
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I misinterpreted the route variable in navigation_transition as Route rather than ActivatedRouteSnapshot. LGTM

Comment on lines 828 to 841
loadComponent: () => of(LazyLoadedStandaloneComponent).pipe(delay(100)),
canActivate: [() => of(true).pipe(delay(200))],
},
]);

router.navigateByUrl('/blank');

await advance(fixture);

routerPreloader.preload();

router.navigateByUrl('/lazy');

await advance(fixture, 400);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these delays need to be so large? This test will take half a second, which seems unnecessarily long

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that such large delays are unnecessary. The delays have been reduced

@atscott atscott added the target: patch This PR is targeted for the next patch release label Jul 8, 2025
Preloaded components were not being activated in certain scenarios when preloading was enabled. This change ensures that components are correctly activated after being preloaded.
@dimakuba dimakuba force-pushed the fix-router-load-components branch from 2803c39 to b3f5756 Compare July 8, 2025 16:37
@atscott atscott added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jul 9, 2025
@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 9c45c32.

The changes were merged into the following branches: main

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: router target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants