Skip to content

Commit 567f292

Browse files
leonsenftmattrbeck
authored andcommitted
fix(forms): support custom controls as host directives
Add the missing code to update control properties when control is a host directive. Fix #66592.
1 parent dcb9af6 commit 567f292

2 files changed

Lines changed: 495 additions & 5 deletions

File tree

packages/core/src/render3/instructions/control.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,29 @@ class ControlDirectiveHostImpl implements ControlDirectiveHost {
160160

161161
setInputOnDirectives(inputName: string, value: unknown): boolean {
162162
const directiveIndices = this.tNode.inputs?.[inputName];
163-
if (!directiveIndices) {
163+
const hostDirectiveInputs = this.tNode.hostDirectiveInputs?.[inputName];
164+
if (!directiveIndices && !hostDirectiveInputs) {
164165
return false;
165166
}
166-
for (const index of directiveIndices) {
167-
const directiveDef = this.tView.data[index] as DirectiveDef<unknown>;
168-
const directive = this.lView[index];
169-
writeToDirectiveInput(directiveDef, directive, inputName, value);
167+
168+
if (directiveIndices) {
169+
for (const index of directiveIndices) {
170+
const directiveDef = this.tView.data[index] as DirectiveDef<unknown>;
171+
const directive = this.lView[index];
172+
writeToDirectiveInput(directiveDef, directive, inputName, value);
173+
}
174+
}
175+
176+
if (hostDirectiveInputs) {
177+
for (let i = 0; i < hostDirectiveInputs.length; i += 2) {
178+
const index = hostDirectiveInputs[i] as number;
179+
const internalName = hostDirectiveInputs[i + 1] as string;
180+
const directiveDef = this.tView.data[index] as DirectiveDef<unknown>;
181+
const directive = this.lView[index];
182+
writeToDirectiveInput(directiveDef, directive, internalName, value);
183+
}
170184
}
185+
171186
return true;
172187
}
173188

0 commit comments

Comments
 (0)