Custom directive implementing controlValueAccessor does not trigger writeValue if the formControl has been updated by another controlValueAccessor
- Dominant language
- TypeScript
- Stars
- 101k
- Forks
- 27.5k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 288
Description
### Which @angular/* package(s) are the source of the bug?
forms
### Is this a regression?
No
### Description
I've created a custom directive implementing controlValueAccessor and added it to two html input elements.
The writeValue function is not called if the input value is provided using [formControl] and the value is updated through the registerOnChange callback.
The writeValue is instead correctly called if the input value is provided by [(ngModel)] instead of [formControl]
```
Export class customDirective implements controlValueAccessor ...
With ngModel works fine
With formControl there's the issue
```
### Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/angular-ivy-a2loir?file=src%2Fapp%2Fapp.component.html
### Please provide the exception or error you saw
_No response_
### Please provide the environment you discovered this bug in
_No response_
### Anything else?
_No response_
Contributor guide
Research direction
Start with the linked StackBlitz reproduction and the @angular/forms implementation of ControlValueAccessor, comparing the [formControl] and [(ngModel)] binding paths. Trace the registerOnChange and writeValue calls for two controls sharing the same value, then add or update coverage so the reproduction behaves consistently and writeValue is invoked when the form control changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100