Fix Duplicate ng-template Names#8049
Conversation
| @Input() label: string; | ||
| @ViewChild(TemplateRef) template: TemplateRef<any>; | ||
| @ContentChild('tabLabel') labelTemplate: TemplateRef<any>; | ||
| @ContentChild(TemplateRef) labelTemplate: TemplateRef<any>; |
There was a problem hiding this comment.
Note for Reviewer:
Why I did changed from "string" to TemplateRef
-
@ ContentChild('tabLabel')uses a fixed template name as a shared contract between parent and child, so every<km-tab>must define#tabLabel, which can lead to duplicate names in the same template when multiple siblings exist. -
@ ContentChild(TemplateRef)has no naming contract and simply picks up the projected template per instance, so each<km-tab>resolves its own content independently with no collisions.
|
/test pre-dashboard-web-integration-tests-ce |
1 similar comment
|
/test pre-dashboard-web-integration-tests-ce |
|
LGTM label has been added. DetailsGit tree hash: 45c8af62a3bed11ec28b3f5d2c50c41575581a33 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahmadhamzh The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/test pre-dashboard-web-integration-tests-ce |
What this PR does / why we need it:
Angular enforces unique ng-template names to avoid ambiguity in schematic processing, and this issue was discovered while testing the Angular migration script, as duplicate template names could lead to corrupt or incorrect transformation output.
Angular GitHub references:
Which issue(s) this PR fixes:
Ref: #7675
What type of PR is this?
/kind cleanup
Special notes for your reviewer:
FYI:
Found while running the migration script: it didn’t auto-convert some files and showed a warning, but this is a pure rename to satisfy Angular’s requirement for unique ng-template names within a component, with no behavior change.
Does this PR introduce a user-facing change? Then add your Release Note here:
Documentation:
Test issue: