angular / angular/components

bug(mat-form-field): mat-error not displayed when form field is in an error state.

Đang mở
#19,960 2 bình luận 1 reaction 0 người được giao Xem trên GitHub
area: material/form-field P3
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

#### Reproduction

The Stackllitz app (https://stackblitz.com/edit/yz1dhz-m5re6l) renders two form controls in a form group:

1. A [mat-select](https://material.angular.io/components/select/overview)
2. A [custom form field control](https://material.angular.io/guide/creating-a-custom-form-field-control) (wraps Codemirror)

Both form controls are immediately invalid because they are initailized with null and have a required validator. The error message for each form control is displayed in ``.

Steps to reproduce:
1. Select "Foo" from the `` form control to set the corresponding validator on the second form control (the custom form field).
3. The error message for the second form control is correctly displayed `{ "required": true, "message": "Must be Foo" }`.
4. Enter the value "Foo" into the second form control to move the form control to a valid state.
5. The `` is shown. All good so far :)
6. Select "Bar" from the first form control to set a different validator.
7. The second form control is in an error state and the form field is displayed with a solid red color underline.
8. `` is NOT displayed and the `` is.

![image](https://user-images.githubusercontent.com/1623996/87334183-c3f47700-c52d-11ea-8359-f4e8290d76f2.png)


#### Expected Behavior

`` is hidden and `` is displays `{ "message": "Must be Bar" }`

#### Actual Behavior

`` is hidden and `` is displays `I am a hint.`

#### Environment

- Angular: 9.1.6
- CDK/Material: 9.2.3
- Browser(s): Chrome Version 83.0.4103.116 (Official Build) (64-bit)
- Operating System (e.g. Windows, macOS, Ubuntu): ArchLinux

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 bản tái hiện StackBlitz được liên kết và so sánh mat-select với custom form field control bọc Codemirror. Theo dõi cách mat-form-field chọn giữa mat-error và mat-hint sau khi validator thay đổi; hoàn tất khi thông báo lỗi "Must be Bar" được hiển thị và gợi ý bị ẩn.

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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/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.