bug(Density): Setting the density via mat.all-component-densities gives different result than setting via mat.theme density
- 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
When defining the density via mat.theme, e.g.
```
@include mat.theme(
(
color: (
theme-type: light,
primary: mat.$azure-palette,
tertiary: mat.$blue-palette,
),
typography: Roboto,
density: (
scale: 0,
),
)
);
```
the button height is 40px (`--mdc-text-button-container-height`).
However, using the `mat.all-component-densities(0)` mixin results in button height equals to 36px.
Similar issue applies to other densities - setting the density through the mixin results in different height values than setting it through the `mat.theme` mixin.
### Reproduction
StackBlitz link: https://stackblitz.com/edit/czrubf43?file=src%2Fstyles.scss
Steps to reproduce:
1. inspect the button height without setting the density. Height is 40px
2. set the density height with the dropdown to 0. Height changes to 36px.
changing density through the dropdown adds respectively classes to the body: .density0, .density-1 ... .density-5
the scss for those is (see styles.scss)
```
.body {
&.density0 {
@include mat.all-component-densities(0);
}
...
&.density-5 {
@include mat.all-component-densities(-5);
}
}
```
### Expected Behavior
densities (component heights) set through `mat.all-component-densities(0)` should be the same when set through
`mat.theme((density: 0))`
### Actual Behavior
densities (component heights) set through `mat.all-component-densities(0)` are different when set through
`mat.theme((density: 0))`
### Environment
- Angular: 19.2.5
- CDK/Material: 19.2.5
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): macOS
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với bản tái hiện trên StackBlitz và styles.scss của nó, sau đó so sánh CSS được tạo bởi mat.all-component-densities(0) với cấu hình density được truyền vào mat.theme. Kiểm tra chiều cao của nút và các giá trị density tương ứng cho 0 và các thang đo khác; hoàn tất khi cả hai đường dẫn cấu hình tạo ra cùng chiều cao component.
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, sass
- 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