Problem/Motivation

  • The border of the contextual link button is rather light, in particular in light mode, where the background of the page is also white. The pencil icon appears on hover, but it still requires some cognitive effort to process that there is a button and that this button is clickable (See the table in https://docs.google.com/spreadsheets/d/1won35PxhRFexJYE8FmZ4DCNTo7xEAxC8... or contextual_links.xlsx.zip for more details).
  • the filter media field set in light mode with the contextual link button shown in the upper right corner with the pencil icon shown in yellow accent color
    the filter media field set in dark mode with the contextual link button shown in the upper right corner with the pencil icon shown in yellow accent color

  • The label for the contextual link is redundant and missing a context most of the time. For example on the frontpage in Olivero for Drupal CMS you have in the rotor in VoiceOver eight entries with Open configuration options, toggle button, two entries with Open latest configuration options, toggle button, and three entries that provide a specific context: Open Primary tabs configuration options, toggle button, A celebration of Drupal and open-source contributions configuration options, toggle button, and Open footer configuration options, toggle button. - This is moved to #3623711: Labels for contextual links are redundant and missing a context
  • In Forced Colors mode the contextual link buttons have no pen icon on hover, neither in Gin nor in Olivero. [#Icons are invisible]
  • the filter media field set in forced color mode with the contextual link button shown in the upper right corner with just the border the pencil icon missing

Discussed and iterated on the issue with @mgifford, @the_g_bomb, @katannshaw, and @drupa11y

Steps to reproduce

  • Enable Media, Media Library /admin/modules
  • Check the contextual link buttons on either /admin/content/media-grid
  • For testing the issue in Forced Colors mode make sure that you’ve switched to dark mode before.

Previous sets also suggested that it could be tested "on the frontpage in Olivero."

Proposed resolution

  • Increase the color contrast for the border in light mode so it meets 3:1, so the button gets a higher affordance and gets easier noticed. Same for the dark mode, due to the thin border, the border looks kind of jagged (not sure if that is the right term in english) - it is simply not a clearly recognizable button.
  • Add context to the button label for screenreader users.
  • Consider showing the contextual button in the context of layout builder all the time: https://www.drupal.org/project/drupal/issues/3037742
  • Ensure that the pen icon is shown in Forced Colors mode on hover (related to [#Several icons and images are invisible in Forced Colors mode])

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork drupal-3506333

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
mgifford’s picture

Ok, lets minimize the SVG and have it use the ButtonFace so it is more easily customizable

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="ButtonFace" d="M14.6 3 13 1.4a1 1 0 0 0-1.4 0l-1.3 1.4 3 3 1.2-1.3a1 1 0 0 0 0-1.4M5.2 13.6l-3-3 7-7 3 3zm-4.3 1c0 .3 0 .5.3.4l2-.7-1.6-1.6z"/></svg>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path stroke="ButtonFace" stroke-width="3" d="m2.3 2.3 11.4 11.4m-11.4 0L13.7 2.3"/></svg>

I think there will be better ways to do this, but just looking at the issue of the forced colors mode

@media (forced-colors: active) {
  /* Contextual trigger (pen icon) */
  .contextual .trigger {
    forced-color-adjust: none !important;
    background-color: ButtonFace !important;
    color: ButtonText !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='ButtonFace' d='M14.6 3 13 1.4a1 1 0 0 0-1.4 0l-1.3 1.4 3 3 1.2-1.3a1 1 0 0 0 0-1.4M5.2 13.6l-3-3 7-7 3 3zm-4.3 1c0 .3 0 .5.3.4l2-.7-1.6-1.6z'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
    border: 1px solid ButtonText !important;
    width: 26px;
    height: 26px;
    opacity: 1 !important;
  }

  .contextual .trigger:hover,
  .contextual .trigger:focus-visible {
    background-color: Highlight !important;
    color: HighlightText !important;
    outline: 2px solid Highlight !important;
  }

  /* Remove button (X icon) */
  .media-library-item__remove {
    forced-color-adjust: none !important;
    background-color: ButtonFace !important;
    color: ButtonText !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath stroke='ButtonFace' stroke-width='3' d='m2.3 2.3 11.4 11.4m-11.4 0L13.7 2.3'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 0.75rem;
    border: 1px solid ButtonText !important;
    opacity: 1 !important;
  }

  .media-library-item__remove:hover,
  .media-library-item__remove:focus-visible {
    background-color: Highlight !important;
    color: HighlightText !important;
    outline: 2px solid Highlight !important;
  }

  /* Edit button (pen icon) */
  .media-library-item__edit {
    forced-color-adjust: none !important;
    background-color: ButtonFace !important;
    color: ButtonText !important;
    border: 1px solid ButtonText !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='ButtonFace' d='M14.6 3 13 1.4a1 1 0 0 0-1.4 0l-1.3 1.4 3 3 1.2-1.3a1 1 0 0 0 0-1.4M5.2 13.6l-3-3 7-7 3 3zm-4.3 1c0 .3 0 .5.3.4l2-.7-1.6-1.6z'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 0.75rem;
    opacity: 1 !important;
  }

  .media-library-item__edit:hover,
  .media-library-item__edit:focus-visible {
    background-color: Highlight !important;
    color: HighlightText !important;
    outline: 2px solid Highlight !important;
  }
}

There is some JS which is is hiding edit pen when the mouse isn't hovering over the form:

<form class="views-exposed-form" aria-label="Filter the contents of the Media view" data-drupal-selector="views-exposed-form-media-library-page" action="/admin/content/media-grid" method="get" id="views-exposed-form-media-library-page" accept-charset="UTF-8" data-once="exposed-form">

It converts this:

<button class="trigger focusable visually-hidden" type="button" aria-pressed="false">Open  configuration options</button>

to this:
<button class="trigger focusable" type="button" aria-pressed="false">Open configuration options</button>

But it doesn't trigger for keyboard users (focus).

It should always be visible, especially in a high contrast mode.

mgifford’s picture

Project: Gin Admin Theme » Drupal core
Version: 4.0.2 » 11.2.x-dev
Component: User interface » ajax system

This CSS is an issue in both Gin & Claro, so this isn't a Gin specific issue. The CSS works reasonably well in both.

mgifford’s picture

Component: ajax system » media system

This occurs in the media system, but not sure it is restricted to it.

quietone’s picture

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

In Drupal core changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies. Thanks

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

kentr’s picture

Title: Improve the perceptibility of contextual link buttons » [PP-1] Improve the perceptibility of contextual link buttons
Status: Active » Postponed

If I understand correctly, I'm inclined to say that this is a Gin / Default Admin issue.

The icon originates from the contextual module, but AFAICT it's (currently) overridden by Default Admin in contextual_links.css.

I think it's likely that the theme's dark mode will need an override by itself even if the light mode version is unified somehow.

Postponing based on #3582351: [Meta] Clean up CSS within Admin theme until the CSS restructure / refactor is done.

mgifford’s picture

Component: media system » Admin theme

I thought about moving this back to the Gin theme and then copying it so that it is also part of Core (and linking them), but just making it more visible for the Admin theme queue.

Leaving it in #3506302: [Meta] Improve the accessibility of the Gin theme

I also wonder if deleting CSS might be acceptable in the CSS cleanup.

kentr’s picture

Issue tags: +color contrast, +forced colors
mherchel’s picture

Title: [PP-1] Improve the perceptibility of contextual link buttons » Improve the perceptibility of contextual link buttons
Status: Postponed » Active

This is ready to be worked on

mgifford’s picture

Issue summary: View changes

mgifford’s picture

StatusFileSize
new29.89 KB
new27.06 KB
new31.5 KB

Patch added (produced with AI).

Some updated screenshots with the patch applied.

Screenshot with patch in dark mode.

Screenshot with patch in light mode.

Screenshot with patch in forced colors mode.

mgifford’s picture

Status: Active » Needs review
alex ua’s picture

I tested the MR on chromium (in light, dark, and forced colors) using the Default Admin theme at /admin/content/media-grid, and it works as described.

I did note a few small things you might want to look at before a commit:

  • The pencil icon changed from the stroked file icon to a filled inline data URI. Was that intentional?
  • The forced-colors focus outline is a hardcoded 2px vs. the theme's --outline-size is 4px.
  • None of these had a measurable effect: border-color: ButtonText, background: ButtonFace, and box-shadow:

FWIW I also didn't test in any other browser besides Chrome.

Generated with the help of an LLM, but written (mostly) by me.

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

smustgrave’s picture

Pushed a fix to use a svg file to address the first bullet.

As as the 2nd bullet not sure which is correct 2px or 4px

For the 3rd bullet wonder if it was because they were capitalized? Pushed a change up for that.

smustgrave’s picture

Status: Needs review » Needs work

Add context to the button label for screenreader users

Seems like this step is still missing.

mherchel’s picture

Issue summary: View changes
Status: Needs work » Needs review

The button context issue is real, but this functionality doesn't belong in the theme. It belongs in the contextual module, so it can apply to all themes.

I opened up a followup #3623711: Labels for contextual links are redundant and missing a context to get that fixed.

mherchel’s picture

Issue summary: View changes
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new102.01 KB

test

believe tested right, used a high contrast chrome plugin with black on yellow setting. Everything appears and focus is is easy to see.

mgifford’s picture

StatusFileSize
new111.65 KB
new62.79 KB
new86.03 KB

I've attached 3 screenshots from Tugboat. The contrast seems a lot better https://contrast.report/

Nice to see this improve.

mherchel’s picture

This looks great to me! There's a couple unrelated bugs that I found while testing this:

  • Sometimes contextual links take two clicks to open.
  • When the button is focused, the text shows to the left.

  • mherchel committed 09fef26d on main
    fix: #3506333 Improve the perceptibility of contextual link buttons
    
    By...
mherchel’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Committed and pushed 09fef26db8c to main. Thanks!

mherchel’s picture

mherchel changed the visibility of the branch main to hidden.

mherchel’s picture

I want to make sure tests pass before backporting.

  • mherchel committed 14b963ac on 11.x
    fix: #3506333 Improve the perceptibility of contextual link buttons
    
    By...
mherchel’s picture

Status: Patch (to be ported) » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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