Skip to content

fix(@schematics/angular): do not add changeDetection in default template#32752

Closed
cexbrayat wants to merge 1 commit intoangular:mainfrom
cexbrayat:fix/component-change-detection-eager-condition
Closed

fix(@schematics/angular): do not add changeDetection in default template#32752
cexbrayat wants to merge 1 commit intoangular:mainfrom
cexbrayat:fix/component-change-detection-eager-condition

Conversation

@cexbrayat
Copy link
Member

PR Checklist

Please check to confirm your PR fulfills the following requirements:

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
  • Other... Please describe:

What is the current behavior?

As the new default is Eager, the CLI was adding changeDetection: ChangeDetectionStrategy.Eager in every component

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

As the new default is `Eager`, the CLI was adding `changeDetection: ChangeDetectionStrategy.Eager` in every component
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes an issue where the default change detection strategy (Eager) was explicitly added to generated components. The component template is updated to avoid adding the changeDetection property when the strategy is 'Eager'. A new test case is included to verify this behavior. The changes appear correct and align with the goal of not specifying the default change detection strategy in the generated code.

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

This is intended as ChangeDetectionStrategy.Eager needs to be explicitly set. We should not add ChangeDetectionStrategy.OnPush which is now the default instead.

Maybe we should also update the schematics default to OnPush to align with the FW default.

@cexbrayat
Copy link
Member Author

@alan-agius4 Thanks for your feedback, I'll close this one and opened #32753 instead which switches the default to OnPush and don't add it to the decorator when that's the case.

@cexbrayat cexbrayat closed this Mar 11, 2026
@cexbrayat cexbrayat deleted the fix/component-change-detection-eager-condition branch March 11, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants