Repository navigation
fix(forms): gate invalid state on touched or dirty - #17674
viktorkombov wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Radio-group touch forwarding can overwrite child controls’ own callbacks in two code paths.
Review effort: Lite
Findings: None
What changed in this PR
Fixes invalid-state rendering for form-bound checkbox, switch, and radio controls by gating it on touched/dirty state.
Changes:
- Adds gated invalid accessors and radio-group validity synchronization.
- Improves radio touch callback forwarding.
- Adds regression tests, documentation, and changelog updates.
| File | Description |
|---|---|
skills/igniteui-angular-components/references/form-controls.md |
Documents touched/dirty invalid styling. |
projects/igniteui-angular/switch/src/switch/switch.component.ts |
Delegates invalid accessors to the base directive. |
projects/igniteui-angular/switch/src/switch/switch.component.spec.ts |
Tests cross-field invalid-state behavior. |
projects/igniteui-angular/radio/src/radio/radio.component.ts |
Delegates invalid accessors to the base directive. |
projects/igniteui-angular/radio/src/radio/radio-group/radio-group.directive.ts |
Gates validity and forwards touch callbacks. |
projects/igniteui-angular/radio/src/radio/radio-group/radio-group.directive.spec.ts |
Tests radio-group reset behavior. |
projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts |
Implements gated invalid state. |
projects/igniteui-angular/checkbox/src/checkbox/checkbox.component.ts |
Delegates invalid input to the base setter. |
projects/igniteui-angular/checkbox/src/checkbox/checkbox.component.spec.ts |
Tests reset behavior. |
CHANGELOG.md |
Records the forms behavior fix. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
The group handed its onTouched callback to every radio button, which overwrites the single callback slot a button bound to its own form directive already filled. Marking the group's control touched from the blur handler it already subscribes to needs no callback on the buttons at all, so nothing can be clobbered and no per-button guard is needed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…into vkombov/fix-17671
|
Regression: a touched field no longer shows invalid after it stops being readonly
Cause:
Suggestion: keep only the touched/dirty check in the
Behaviour change for reactive and template-driven forms The new check also applies to I'm not sure whether this is the intended behaviour. If it is, please, mention it in the changelog for all form types; |
Closes #17671
Description
With
[formField], Angular writes the field's rawinvalid()into theinvalidinput ofigx-checkbox,igx-switchandigx-radio-groupwhenever it changes, bypassing the touched-or-dirty rule these controls apply for reactive and template-driven forms — e.g. a pristine field painted the error style right afterreset()or when a cross-field rule made it required. Same ordering issue #17637 fixed forrequired.invalidis now a gated setter onCheckboxBaseDirectiveandIgxRadioGroupDirective: with a bound form control,trueis coerced tofalsewhile the control is untouched and pristine (checkbox/switch/radio became delegating accessors to keep@Input/@HostBinding).invalidfrom the control on status changes instead of always clearing it, since Signal Forms only push validity on change.registerOnTouchednever reaching the radio buttons (the forms directive registers before any buttons exist), so blur now marks the field touched.Tests: 3 new regression specs (fail without the fix); full non-grid suite green (3386), lint clean. Changelog updated; no API changes.
🤖 Generated with Claude Code
Type of Change (check all that apply):
Component(s) / Area(s) Affected:
How Has This Been Tested?
Test Configuration:
Screenshots / Recordings
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)