angular / angular/components

bug(material/core): Theme configuration checks should allow extra slots in color palettes

Đang mở
#30,780 2 bình luận 2 reaction 0 người được giao Xem trên GitHub
area: ng-generate feature P4
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

The [Material Theme Builder](https://material-foundation.github.io/material-theme-builder/) generates slots 5 and 15 in the color palettes.

Image

These should be allowed to be included in the color palettes even if they are not used by Angular Material.

However when I try to include those slots in a theme for Angular Material, the sass complier errors with "Expected $config.primary to be a valid M3 palette". The error is generated by https://github.com/angular/components/blob/c4337d635e3c87b029136c7eaa707df9f2a07163/src/material/core/theming/_config-validation.scss#L38 and https://github.com/angular/components/blob/c4337d635e3c87b029136c7eaa707df9f2a07163/src/material/core/theming/_config-validation.scss#L44

The validation checks should only fail on required (i.e. used by Angular Material) slots.

### Reproduction

StackBlitz link:
Steps to reproduce:
1. Generate a theme using `ng generate @angular/material:theme-color`
2. In any of the color palettes, add an extra value to the map, e.g. `5: #1e0037`.
3. `ng build`

### Expected Behavior

The build completes without error.

### Actual Behavior

The build failed with error.

```
✘ [ERROR] (Expected $config.primary to be a valid M3 palette. Got: (0: #000000, 5: #1e0037, ... )))
51 │ definition.define-colors($color));
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

node_modules/@angular/material/core/tokens/_m3-system.scss 51:13 theme()
```

### Environment

- Angular: 19.2.5
- CDK/Material: 19.2.7

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 src/material/core/theming/_config-validation.scss tại các bước kiểm tra quanh dòng 38 và 44, sau đó tái hiện lỗi bằng cách thêm slot 5 vào một palette được tạo bằng ng generate @angular/material:theme-color và chạy ng build. Hoàn thành khi palette được tạo có các slot bổ sung được build mà không gặp lỗi palette M3 hợp lệ.

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ó
2/5
Thời gian dự kiến
1-3 giờ
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
48/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.