Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(style): Custom palette's text hue not propagated to MDC styles #29076

Open
1 task done
benelliott opened this issue May 20, 2024 · 2 comments
Open
1 task done

bug(style): Custom palette's text hue not propagated to MDC styles #29076

benelliott opened this issue May 20, 2024 · 2 comments
Labels
area: material/form-field P4 A relatively minor issue that is not relevant to core functions

Comments

@benelliott
Copy link
Contributor

benelliott commented May 20, 2024

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

14.x

Description

[Re-opening #26021 which was incorrectly closed as a duplicate of a similar but different issue]

[This is a regression insofar as the legacy non-MDC implementations do not have this problem]

Hi, after running the MDC schematic on one of my projects I have found that the MDC-based components do not use the $text hue specified in the theme config, which can cause accessibility issues for themes whose default hues do not provide sufficient contrast against a neutral background. In particular I have noticed this causes legibility issues for the floating placeholder on form fields and the label text on default-appearance buttons, but it might apply to other components as well.

My theme is configured as follows:

$my-palette: mat.define-palette($greens, 600, 200, 900, 700);
Note that the $text hue is overridden to 700 in the call to define-palette.

Here is a screenshot showing the 700 hue being correctly applied to the aforementioned text elements under the legacy components:

image

And here is how the new MDC components look:

image

I had a hard time reading the Angular Material => MDC SCSS theming code but it seems like the $text hue preference isn't being passed to the MDC mixins in any way.

Reproduction

StackBlitz link:
Steps to reproduce:

  1. https://stackblitz.com/edit/components-issue-9ugktp?file=src%2Fstyles.scss
  2. Note that text hue is set to 900 but text button and form field label use 500

Expected Behavior

MDC components should use specified text hue where applicable

Actual Behavior

MDC components used primary hue regardless

Environment

Environment
Angular: 15.0.0-18.0.1
CDK/Material: 15.0.0-18.0.1
Browser(s): Chrome
Operating System (e.g. Windows, macOS, Ubuntu): Windows 10

@benelliott benelliott added the needs triage This issue needs to be triaged by the team label May 20, 2024
@benelliott
Copy link
Contributor Author

benelliott commented May 20, 2024

This is not a duplicate of #26056, which was resolved by using palette contrast values where applicable instead of hardcoded #000 / #fff.

@crisbeto crisbeto added P4 A relatively minor issue that is not relevant to core functions area: material/form-field and removed needs triage This issue needs to be triaged by the team labels May 22, 2024
@benelliott
Copy link
Contributor Author

Thanks @crisbeto for tagging - thought it might be worth noting that this affects a range of components including buttons and tabs as well as form fields. Maybe an issue can only be tagged under one area though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/form-field P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

2 participants