Custom directive implementing controlValueAccessor does not trigger writeValue if the formControl has been updated by another controlValueAccessor
- 主要語言
- TypeScript
- 星號
- 101k
- 分支
- 28k
- 平均合併
- 1 天 20 小時
- 30 天內合併 PR
- 299
描述
### 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_
貢獻指南
研究方向
從連結的 StackBlitz 重現開始,並查看 @angular/forms 中的 ControlValueAccessor 實作,比較 [formControl] 和 [(ngModel)] 的繫結路徑。追蹤兩個共用相同值的控制項對 registerOnChange 和 writeValue 的呼叫,然後新增或更新覆蓋率,讓重現行為保持一致,並在表單控制項變更時呼叫 writeValue。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- angular, typescript
- 領域
- frontend
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100