ContrastChecker component doesn't process CSS variables #20508
Labels
[Feature] Themes
Questions or issues with incorporating or styling blocks in a theme.
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Type] Enhancement
A suggestion for improvement.
Describe the bug
It's possible to register an editor color palette using CSS variables as colors, like this:
However, no matter what the CSS variable is defined as, the contrast checker message displays "This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.".
Expected behavior
I believe this is happening because tinycolor2 evaluates any unrecognized color format as black. It would be better, in cases like this where tinycolor doesn't recognize the color format, to fall back to the detected color from
getComputedStyle()
, which can properly return the value of the CSS variable.Desktop (please complete the following information):
Additional context
I tested using the block editor from core 5.3.2, and also using the latest plugin release 7.6.0.
The text was updated successfully, but these errors were encountered: