bug(mat-form-filed): padding added to mat-icon when used as a prefix/suffix does not respect density
- Dominant language
- TypeScript
- Stars
- 25k
- Forks
- 6.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 91
Description
### 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):
Contributor guide
Research direction
Start with the .mat-mdc-form-field-icon-prefix > .mat-icon and .mat-mdc-form-field-icon-suffix > .mat-icon rules described in the issue, then reproduce the three cases in the linked StackBlitz at minimum density. Done means direct mat-icon prefix and suffix padding changes with form-field density while the mat-icon-button and wrapped-icon cases retain their current behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, css, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100