Skip to content

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

Open
@rgylesbedford

Description

@rgylesbedford

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 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

@if validation.validate-allowed-values($keys, $expected-keys...) or
and
@if validation.validate-allowed-values($nv-keys, $expected-nv-keys...) or

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: ng-generateSchematics that generate code in user projectsfeatureThis issue represents a new feature or feature request rather than a bug or bug fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions