angular / angular/angular

Custom directive implementing controlValueAccessor does not trigger writeValue if the formControl has been updated by another controlValueAccessor

Đang mở
#43,484 4 bình luận 17 reaction 0 người được giao Xem trên GitHub
area: forms P3
Ngôn ngữ chính
TypeScript
Star
101k
Fork
27.5k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
288

Mô tả

### 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_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với reproduction StackBlitz được liên kết và implementation của ControlValueAccessor trong @angular/forms, đồng thời so sánh các binding path của [formControl] và [(ngModel)]. Truy vết các lần gọi registerOnChange và writeValue cho hai control dùng chung một giá trị, sau đó thêm hoặc cập nhật coverage để reproduction hoạt động nhất quán và writeValue được gọi khi form control thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.