Problem/Motivation

Form labels that are disabled have too low color contrast.

the unchangeable media source section of an existing media type

The bold label has a foreground color of #828388 with a background color of #FEFFFE which leads to a contrast ration of 3,8:1. The calculated font size is at 14.223999977111816px. To qualify as large text the text would have to be bold and at least 18.5px therefor it is categorised as regular text and needs a contrast ratio of 4.5:1 to pass.

The select box text has a color of #828388 and a background-color of #F2F2F3 which is a contrast of 3.4:1 with a font size of 16px. The aforementioned contrast ratio passes for large text (requirement 3:1) but fails for regular text (requirement 4.5:1). But with 16 px the displayed text doesn't qualify for large text (requirement either 24px or bold and at least 18,5px).
Same for the non-text contrast of the svg background-image (.form-element--type-select[disabled]). foreground color is #8E929C and background color is #f2f2f3 which leads to a contrast ratio of 2.8:1 but 3:1 is required for non text contrast.
And speaking of non-text contrast the outline of the select box has a too low contrast ratio as well. the border color is #bababf while the background color is #f2f2f3 which leads to a contrast of 1.7:1 but 3:1 is required. (*disclaimer with outlines and borders i am not entirely sure if it is necessary to get things to pass or not)

The edit source description (id is edit-source--description) has a color of #828388 with a background color of #FEFFFE that is a contrast ratio of 3.8:1. To pass with a calculated font-size of 12.640000343322754px the ratio would need to be 4.5:1 for regular text.

Steps to reproduce

- Install the Media module in Core
- Go to the image field in admin/structure/media/manage/image or one of the existing media types
- Check the media source section to see that the contrast has been updated to meet WCAG 2.0 AA (should be #75767b rather than #828388)

Issue fork drupal-3266299

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rkoller created an issue. See original summary.

rkoller’s picture

Issue summary: View changes
mherchel’s picture

Title: The set media source section of a media type has a too low color contrast » Claro: Form labels that are disabled have too low color contrast
Issue summary: View changes
Issue tags: +CSS, +Accessibility, +color contrast

The label is this color because of the .is-disabled CSS class on it. Updating the issue summary.

I somewhat recall having a discussion in the Olivero issue queue where it is okay to have disabled text not meet contrast criteria... but I'm not 100% sure.

I'm going to cross post this in the Drupal Slack #accessibility channel for feedback

https://drupal.slack.com/archives/C2ANFUGGG/p1649851821588239

ckrina’s picture

I commented this on the duplicated issue #3266760: Greyed out authenticated user role in user profile has a too low color contrast:
The element .form-item__label.is-disabled is using the variable --input--disabled-fg-color. It is defined in the variables.pcss.css file on line 104 as --input--disabled-fg-color: var(--color-gray-600). Instead of --color-gray-600 it should be using --color-gray-700, with a contrast ratio of 4.53. It'll solve this existing problem in all disabled labels.

That issue can be addressed here, changing the color for all elements involved.

mikemai2awesome’s picture

Bringing some comments from Slack:

@Mike Mai:

general question. why have disabled form elements at all? if certain feature is locked down, isn’t it pure information at that point?

@mherchel:

IMHO, its still valuable because it does convey information. The info that it conveys are "You are in the correct area of the admin interface (you don't have to look around futher). But... something's still not right and we can't make a change"

@Mike Mai:

fair point, i do believe there’s a different way of design to convey that without making the element completely illegible for some people.

@ckrina:

Should just the label change, or all the elements should respect the4.5:1 ratio? Like the select value in the issue image example “Image”, or the description. From your comments I assume all or them, but not sure

@Mike Mai:

this is me speaking out of context of your design guidelines and design system, so forgive me: for the <label> it really has no reason to visually make it disabled, it is not disabled itself. for the <select>, i do understand using the disabled attribute for the points above, however, visually it can be done differently. for example, use a lock icon (or another appropriate icon) along with the select element, then use the same icon in front of the helper text right below the select element to make the connection. i don’t believe dimming the entire select element to fall below 4.5:1 is a good approach.

ckrina’s picture

We discussed this during the weekly Claro meeting. Here is the thread: https://drupal.slack.com/archives/C2ANFUGGG/p1649851821588239

@andrewmacpherson added this feedback:

In terms of must-have vs should-have, I'd like to treat the separately from the labels and descriptions.
For the disabled inputs, they have an explicit WCAG exemption, so it's a could-have.
I'm leaning towards must-have for the labels and descriptions contrast. These are rather crucial to read and understand. IMO these don't explicitly fall under the "incidental" WCAG exemption.

So I would suggest next steps are, based on @andrewmacpherson and @mikemai2awesome feedback:

  1. Change grays for disabled labels and descriptions here to --color-gray-700, that complies with the 4.5:1 contrast requirement.
  2. Open follow-up to find a design solution that gets a contrast of 3:1 for inputs.
  3. Open follow-up to find a design solution that communicates when a field is disabled. Maybe using a visual clue or rethink if the info needs to look like a disabled input or another way that gives enough info on why it can't be changed.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

stueybrock made their first commit to this issue’s fork.

stueybrock’s picture

StatusFileSize
new27.69 KB

Screenshot of updated colour of disabled input description

Pushed change to disabled colour

smustgrave made their first commit to this issue’s fork.

smustgrave’s picture

Status: Active » Needs review

Fixed CI error.

mgifford’s picture

Issue summary: View changes

I tried to test this in SimplyTest.me but couldn't seem to get the patch to apply there. Not sure if its just too long since I did this, or if there is another bug in SimplyTest.me.

Wanted to raise this related issue:

Title: WCAG 1.4.3: Ensures the contrast between foreground and background colors meets WCAG 2 AA contrast ratio thresholds (em)
Tags: Accessibility, WCAG 1.4.3, color-contrast

Issue: Ensures the contrast between foreground and background colors meets WCAG 2 AA contrast ratio thresholds (color-contrast - https://accessibilityinsights.io/info-examples/web/color-contrast)

Target application: Edit Image | Drush Site-Install - https://master-5cugo26zvm3mikgfxjfznly18jm9g8jb.tugboatqa.com/admin/stru...

Element path: #edit-source--description > em

Snippet: The media source cannot be changed after the media type is created.

How to fix:
Fix any of the following:
Element has insufficient color contrast of 3.78 (foreground color: #828388, background color: #ffffff, font size: 9.5pt (12.64px), font weight: normal). Expected contrast ratio of 4.5:1

Environment: Microsoft Edge version 105.0.1343.50

====

This accessibility issue was found using Accessibility Insights for Web 2.34.1 (axe-core 4.4.1), a tool that helps find and fix accessibility issues. Get more information & download this tool at http://aka.ms/AccessibilityInsights.

smustgrave’s picture

So this is how I tested

Drupal 9.5 standard install
Making claro my default theme
Using https://www.drupal.org/project/examples
Ajax submodule specifically
Went to examples/ajax-example/dependent-dropdown
Using color contrast analyzer verified the failure.
Applied MR
Verified color contrast now passes.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mgifford’s picture

Issue tags: +WCAG 143

Tagging for WCAG 1.4.3

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new150 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

smustgrave’s picture

This actually appears to have already been fixed. If anyone can confirm we can close this out.

sahil.goyal’s picture

StatusFileSize
new657.8 KB

Color contrast is changed and updated after applying MR on 9.5x but it not getting applied to the D10.0.x it still shows old color contrast as color: #828388. i think it needs to be updated..

rkoller’s picture

StatusFileSize
new13.31 KB

without applying the patch this isn't fixed at all. i've rechecked with a current install of 10.1.xdev. the media source label still has a color contrast of 3,78:1 (#828388). i have saved me to recheck the rest of the color contrasts. the issue is still relevant and necessary. only problem is the patch doesn't apply anymore with composer patches.

one idea. i am not really a fan of disabled interface elements. they have those a11y implications which were the reason this issue was initially created plus they are potentially confusing from an ux perspective. in the case of the set media type why not drop the greyed out display for disabled select form elements and instead make it an informal badge? i've just chopped it together in devtools. i've just removed the is-disabled classes and switched off the background image for the pointing down arrow.
media source not greyed out and the select form arrow removed

would definitely need design input but i just wanted to communicate the general gist. the user is unable to make adjustments and is just presented with the media source for the current media type. the description underneath would have to be slightly adjusted. but from my point of view that would fix at least the disabled form media source form elements problems. it would be clear to the user no interaction is necessary, what the media source is and the contrast issues would be avoided.

gauravvvv’s picture

Status: Needs work » Needs review
StatusFileSize
new1.52 KB

Patch #13, no longer applies to 10.1.x. I have provided updated patch for same. please review

amietpatial’s picture

StatusFileSize
new113.27 KB

#22 applied successfully, attaching the screenshot of what I see on 10.1.0-dev

smustgrave’s picture

Status: Needs review » Needs work
StatusFileSize
new152.15 KB

Using a contrast tool the label passes but not the field.

fail

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gauravvvv’s picture

Status: Needs work » Needs review
StatusFileSize
new26.14 KB
new274.76 KB

After patch

Here is the results from contrast tool.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Believe this is good

  • nod_ committed 271a5561 on 10.3.x
    Issue #3266299 by Gauravvvv, stueybrock, smustgrave, rkoller,...

  • nod_ committed 8e344072 on 10.4.x
    Issue #3266299 by Gauravvvv, stueybrock, smustgrave, rkoller,...

  • nod_ committed 22b06e00 on 11.0.x
    Issue #3266299 by Gauravvvv, stueybrock, smustgrave, rkoller,...

  • nod_ committed e8298e81 on 11.x
    Issue #3266299 by Gauravvvv, stueybrock, smustgrave, rkoller,...
nod_’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed e8298e81ba to 11.x and 22b06e0042 to 11.0.x and 8e344072b3 to 10.4.x and 271a556170 to 10.3.x. Thanks!

amietpatial’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.