Skip to content

fix(forms): reflect required validators in compat fields#68911

Open
KirtiRamchandani wants to merge 1 commit into
angular:mainfrom
KirtiRamchandani:fix/compat-form-required-validator
Open

fix(forms): reflect required validators in compat fields#68911
KirtiRamchandani wants to merge 1 commit into
angular:mainfrom
KirtiRamchandani:fix/compat-form-required-validator

Conversation

@KirtiRamchandani
Copy link
Copy Markdown

Problem

compatForm wraps reactive FormControls, but the signal-forms required state does not reflect a wrapped control that has Validators.required. This leaves FieldTree#required false even when the reactive control reports the required validator.

Fixes #68905.

Root cause

Compat field nodes inherit FieldNode.required, which only reads signal-forms REQUIRED metadata. Reactive form validators on the wrapped AbstractControl are not included in that metadata.

Solution

Expose required from CompatFieldNode by deriving a signal from the wrapped control's hasValidator(Validators.required) state, using the existing control-status signal helper so validator updates and control swaps are observed.

Tests run

  • corepack pnpm bazel test //packages/forms/signals/test/node:test --test_arg=--filter='picks up the required state from a reactive form control' --test_output=errors
  • corepack pnpm bazel test //packages/forms/signals/test/node:test --test_output=errors
  • npx --yes prettier@3.8.3 --check packages\forms\signals\compat\src\compat_field_node.ts packages\forms\signals\test\node\compat\compat.spec.ts
  • git diff --check

@pullapprove pullapprove Bot requested a review from JeanMeche May 25, 2026 02:45
@ngbot ngbot Bot added this to the Backlog milestone May 25, 2026
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.

[Signal Forms] compatForm signal form required state does not reflect Validators.required

1 participant