Repository navigation
Conversation
CVA and native hosts receive the field's unfiltered `errors`, so a parse error from one control shows up on every other control bound to the same field. `NgControl.errors` has the same leak. Custom controls still receive the filtered errors. These specs assert the expected behavior and fail on purpose. The triage notes trace the regression to a refactor. A fix will replace the notes once maintainers confirm the intended behavior.
Member
|
Going to close the PRs as they're won't me merged as is. Let's move the discussions to the issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #71632 | Triage notes | Repro specs
Why the change
When one field has several controls, CVA and native hosts receive every control's parse errors instead of only their own, a regression from the refactor that moved control logic into
FormField; this draft adds failing repro specs and asks you to confirm the intended behavior before I write the fix.Special things to note
ebae211addfilterederrorsper control for every host, anda67e00741ckept the filter only for custom controls.invalidstays field-level. Every control still receivesinvalid: true.Change outline
What the branch adds:
How each host reads
errorstoday:Recommended fix: one code path for every host
src/directive/bindings.ts:src/directive/control_custom.tsdrops its special case:for (const name of CONTROL_BINDING_NAMES) { - let value: unknown; - if (name === 'errors') { - value = parent.errors(); - } else { - value = readFieldStateBindingValue(state, name); - } + const value = readFieldStateBindingValue(parent, name);src/directive/control_cva.tsandsrc/directive/control_native.ts:Optional, same intent:
NgControl.errorsFormFieldcreates oneInteropNgControlper binding, but builds it from the field state only, soinject(NgControl).errorshas the same leak:// src/directive/form_field.ts get interopNgControl(): InteropNgControl { - return (this._interopNgControl ??= new InteropNgControl(this.state)); + return (this._interopNgControl ??= new InteropNgControl(this.state, this.errors)); } // src/controls/interop_ng_control.ts - constructor(protected field: () => ReadonlyFieldState<unknown>) {} + constructor( + protected field: () => ReadonlyFieldState<unknown>, + private readonly bindingErrors: () => readonly ValidationError[], + ) {} get errors(): ValidationErrors | null { - return signalErrorsToValidationErrors(this.field().errors()); + return signalErrorsToValidationErrors(this.bindingErrors()); }Alternative considered
Copy the special case from
control_custom.tsintocontrol_cva.tsandcontrol_native.ts. That'sthe smallest diff, but keeping three copies is how the behavior drifted.
Design decisions
errorsfor every host. Recommended, because it restores the documented intent.ebae211addsays: "we only want to report parse errors that are relevant for this particular UIcontrol."
22afbb2f36says a native parse error "is added for the control that received theun-parsable value."
invalidstays field-level. It was never filtered, even inebae211add. A control canreceive
invalid: truewith an emptyerrors, which is what custom controls get today.NgControl.errorsin the same fix, or leave it for a follow-up. CVAcomponents written for reactive forms often read
NgControl.errorsto show their own errorstate.
Questions for maintainers
controls do today?
NgControl.errorsbe filtered in the same PR?invalid: truewith noerrorswhen another control onthe same field has the parse error?
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #71632
What is the new behavior?
No behavior changes yet. This PR adds failing repro specs and triage notes. The fix will replace the
notes on this branch once the questions above are answered.
Does this PR introduce a breaking change?