Skip to content

Conversation

@JoostK
Copy link
Member

@JoostK JoostK commented Mar 9, 2025

This commit fixes a regression that was introduced in #27427, where the injector hierarchy
did not respect nested environment injectors. DomPortalOutlet was always using the application
root as environment injector, yet the element injector may have a custom child environment injector
as ancestor. This child environment injector has to be retrieved manually and passed as environment
injector of the portal component.

Fixes #30609

…et` and child environment injectors

This commit fixes a regression that was introduced in angular#27427, where the injector hierarchy
did not respect nested environment injectors. `DomPortalOutlet` was always using the application
root as environment injector, yet the element injector may have a custom child environment injector
as ancestor. This child environment injector has to be retrieved manually and passed as environment
injector of the portal component.

Fixes angular#30609
@JoostK JoostK requested a review from a team as a code owner March 9, 2025 16:52
@JoostK JoostK requested review from andrewseguin and crisbeto and removed request for a team March 9, 2025 16:52
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM. The timepicker test failures are probably because of the DST change in the US.

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Mar 9, 2025
…peated non-null assertion

This also has the benefit of minimizing more effectively, as the local variable can be renamed
but the separate field accesses could not.
@JoostK JoostK force-pushed the cdk/portal/env-injector branch from 6399c2d to 7705be6 Compare March 9, 2025 17:12
@JoostK JoostK added the target: patch This PR is targeted for the next patch release label Mar 9, 2025
@crisbeto crisbeto removed the request for review from andrewseguin March 10, 2025 15:55
@crisbeto crisbeto merged commit d0d5de4 into angular:main Mar 10, 2025
20 of 22 checks passed
@crisbeto
Copy link
Member

The changes were merged into the following branches: main, 19.2.x

crisbeto pushed a commit that referenced this pull request Mar 10, 2025
…t and child environment injectors (#30610)

* fix(cdk/portal): fix incorrect injector hierarchy with `DomPortalOutlet` and child environment injectors

This commit fixes a regression that was introduced in #27427, where the injector hierarchy
did not respect nested environment injectors. `DomPortalOutlet` was always using the application
root as environment injector, yet the element injector may have a custom child environment injector
as ancestor. This child environment injector has to be retrieved manually and passed as environment
injector of the portal component.

Fixes #30609

* refactor(cdk/portal): store application in local variable to avoid repeated non-null assertion

This also has the benefit of minimizing more effectively, as the local variable can be renamed
but the separate field accesses could not.

(cherry picked from commit d0d5de4)
@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 Apr 10, 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: cdk/portal target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullInjectorError errors after Angular 19 upgrade

3 participants