angular / angular/components

bug(mat-form-filed): padding added to mat-icon when used as a prefix/suffix does not respect density

Đang mở
#26,529 1 bình luận 8 reaction 0 người được giao Xem trên GitHub
area: material/icon 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ả

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Any mat-icon with the matPrefix or matSuffix directive applied to it appears to always have this rule
.mat-mdc-form-field-icon-prefix>.mat-icon, .mat-mdc-form-field-icon-suffix>.mat-icon {
padding: 12px;
box-sizing: content-box;
}
This padding is always the same no matter what density used used for the mat-form-field. Causes form-fields to be taller then they should be when they have an mat-icon prefix/suffix and using smaller densities. Aligns the actual input at the top of the form-field.

### Reproduction

Steps to reproduce:
1. Set density for mat-form-field to minimum
2. Create an mat-form-field with a mat-icon as its mat-suffix

https://stackblitz.com/edit/angular-wxbcwr-7qsjkw?file=src%2Fapp%2Finput-prefix-suffix-example.html

The example contains 3 fields, first one uses a mat-icon-button instead of a mat-icon directly, second uses a mat-icon, 3rd wraps the mat-icon in a span.

In cases 1 and 3 no padding is applied, in the second one 12 pixels of padding is applied to the mat-icon regardless of density settings.

### Expected Behavior

Padding applied to mat-icon with a matSuffix/matPrefix directive should be adjusted based on the density of the mat-form-field

### Actual Behavior

Padding for a mat-icon with a matSuffix/matPrefix directive is always 12 pixels.

### Environment

- Angular:
- CDK/Material:
- Browser(s):
- Operating System (e.g. Windows, macOS, Ubuntu):

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 các quy tắc .mat-mdc-form-field-icon-prefix > .mat-icon và .mat-mdc-form-field-icon-suffix > .mat-icon được mô tả trong issue, sau đó tái hiện tối thiểu ba trường hợp trong StackBlitz được liên kết ở mật độ tối thiểu. Công việc được xem là hoàn tất khi padding của prefix và suffix mat-icon trực tiếp thay đổi theo mật độ của form-field, trong khi các trường hợp mat-icon-button và wrapped-icon vẫn giữ nguyên hành vi hiện tạ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, css, 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
Khá 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.