`ControlValueAccessor` missing `registerOnDisabledStateChanged` method
- Dominant language
- TypeScript
- Stars
- 101k
- Forks
- 27.5k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 288
Description
### Which @angular/* package(s) are relevant/related to the feature request?
forms
### Description
Given that custom form field controls are able to notify listeners of touched/value changes, and the disabled state of a custom form field control can be set using `setDisabledState`, it makes sense that custom form controls should also be able to notify listeners of disabled state changes.
One example is a reusable nested `FormGroup` that can be marked as "skippable".
Another example is a component that is able to stand on its own or be used as part of a form. This component may or may not be associated with a form. If it isn't part of a form (stands alone), the parent component should be able to disable it using an input. Being able to notify listeners of disabled state changes would make implementing form field controls that can also stand on their own more straight forward.
My current impulse is not to allow components intended to be used as custom form field controls to be used as stand alones. Requiring them to be driven by a control instead of having them implement an awkward middle ground where they can be controlled by both a parent component through inputs OR a control.
### Proposed solution
Add a `registerOnDisabledStateChanged` method to the `ControlValueAccessor` interface or a derived interface.
or.
Leave things as they are and continue requiring a control to drive CVAs as we always have.
### Alternatives considered
The bound `NgControl` can be injected into a component and `enable`/`disable` called directly, but this has some quirks, see: https://github.com/angular/angular/issues/29218
Contributor guide
Research direction
Start in the Angular forms package by locating the ControlValueAccessor interface and its setDisabledState handling. Review the related issue #29218 and existing touched/value registration patterns before deciding whether a disabled-state callback belongs in the interface. Done means a resolved API direction with corresponding behavior and tests, or a documented reason to keep the current design.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100