Problem/Motivation

When Gin was moved over from contrib, it used box-shadow as a focus outline (Claro did so too for a while).

However, the vast majority of this has been rectified in default_admin as the CSS was refactored. However there several places where box-shadows may still be utilized as focus outlines. These need to be removed.

The focus outlines also utilize transparency, which can lead to potential issues. We need to refactor that out.

Related is #3619933: Drupal Admin Theme Colors

Steps to reproduce

Proposed resolution

  • Remove transparency from focus outline
  • Remove all box shadows from focus outline
    • There appears to be some left over in media library
    • Remove the variables too
    • Appears to be one box shadow focus state in dropbutton (line 636)
    • Also form checkbox
  • Ensure default focus outline meets 3:1 contrast over lightest surface color

Remaining tasks

User interface changes

Regular foucs

Before

before regular

After

after regular

High contrast

Before

before high

After

after contrast

Introduced terminology

NA

API changes

NA

Data model changes

NA

Release notes snippet

NA

Issue fork drupal-3618140

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

kentr created an issue. See original summary.

kentr’s picture

IS needs updating for Default Admin.

Notes:

  • The values are defined in variables.pcss.css.
  • The current focus indicator is an outline and a box shadow.
  • Outline definition: --focus-outline (currently var(--outline-size) solid var(--admin-color-focus)).
  • Outline width: --outline-size (currently .25rem / 4px).
  • Box shadow definition: --focus-box-shadow (currently 0 0 0 var(--focus-border-offset-size) var(--admin-color-bg-surface), 0 0 0 calc(var(--focus-border-size) + var(--focus-border-offset-size)) var(--admin-color-focus);).
  • The outline does appear in forced-colors mode, but it's still hard to perceive because it's just a thicker version of the button border.
    Focused Appearance Light button in forced colors.
kentr’s picture

Issue summary: View changes

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

mgifford’s picture

Issue tags: +Needs screenshots
mgifford’s picture

Status: Active » Needs review
mgifford’s picture

StatusFileSize
new8.99 KB

There are a number of places where I think we should be setting an outline where it isn't right now. I've included a patch and an interdiff. All AI generated.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

mherchel’s picture

Issue summary: View changes

Met with @mgifford @jurgenhaas @boromor to discuss and refactor the issue summary on this issue, since it's copied verbatim from the Gin issue queue and is out of date.

mgifford changed the visibility of the branch 3618140-improve-the-accessibility to hidden.

mgifford’s picture

With the conflict here https://git.drupalcode.org/project/drupal/-/merge_requests/16774/conflicts

I think we want the new variable names (not gin) but to remove the opacity. So something like:

[data-admin-focus="green"] {
  --admin-color-focus: light-dark(#067a6c, #22b8a5);
}

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

smustgrave’s picture

Issue summary: View changes
smustgrave’s picture

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community

Fixed the performance test now we are all green

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs review

Issue summary called for removing the box shadow which was not entirely removed yet. Also @mgifford raised in #12 the situation of the non-default accents also not meeting accessibility guidelines. So looked at these with LLM guidance.

In accent.pcss.css the four non-default presets now use solid light and dark pairs. Green uses the values @mgifford proposed in #12. The other two pairs are derived the same way, a darker tone for light mode and a lighter one for dark mode, and all meet 3:1 on the theme's lightest and darkest surfaces. The accent preset simply uses the primary colour itself. These are design choices, so need to be reviewed for that.

Preset Light Dark
green #067a6c #22b8a5
legacy_green #1c7d4f #40bc7e
orange #c9552e #f4a07f
accent primary colour primary colour

Also, the media library preview wrapper, the dropbutton item at the old line 636, and the checkbox and radio rings for the checked, error, and error-checked-radio states now rely on the outline only. The two box-shadow variables are removed. The remaining offset variable is renamed to --outline-offset so it sits next to --outline-size instead of using the old box-shadow name; it is used in the same four places as before.

smustgrave’s picture

Could we get updated screenshots?

mherchel’s picture

Taking a look around, it looks like some focus states are still set to box shadow:

  • core/themes/default_admin/css/components/form--checkbox-toggle.pcss.css:71
  • core/themes/default_admin/css/components/icon-link.pcss.css:33 and 47
  • core/themes/default_admin/css/components/node-preview.pcss.css:113
  • core/themes/default_admin/css/components/views-ui.pcss.css:1228

I had Claude scan and it found these

# Location Selector Ring Outline
1 components/form--checkbox-toggle.pcss.css:73 .form-type--checkbox input
&amp;></td>
      <td><code>0 0 0 1px --admin-color-focus-border, 0 0 0 4px --admin-color-focus
none set
2 components/views-ui.pcss.css:1226 .views-tabs .add a:focus same 1px/4px ring outline: none
3 components/node-preview.pcss.css:111 .node-preview-container *:focus same 1px/4px ring outline: none
4 components/icon-link.pcss.css:31 .icon-link:focus
0 0 0 1.5px --admin-color-bg-surface, 0 0 0 3code></td>
      <td>none set</td>
    </tr>
    <tr>
      <td>5</td>
      <td><code>components/icon-link.pcss.css:45
.icon-link--small:focus 0 0 0 1px --admin-color-bg-surface, 0 0 0 3px --admin-color-focus none set
mherchel’s picture

Status: Needs review » Needs work

Everything else looks good besides 👆

gábor hojtsy’s picture

Status: Needs work » Needs review
StatusFileSize
new35.18 KB
new56 KB
new55.79 KB
new36.15 KB
new214.95 KB
new210.66 KB
new35.05 KB
new35.37 KB
new35.58 KB
new35.53 KB
new48.09 KB
new32.01 KB
new33.6 KB
new35.46 KB
new16.2 KB

Asked my agent to help with screenshots because this would have taken hours :) It could not screenshot inside the media dialog, had issues opening it. Otherwise here are the before/afters.

Default outline

Button

Focused button, before and after

Text input

Focused text input, before and after

Theme settings pill radio

Focused pill radio on the theme settings page, before and after

Box shadows replaced by outlines

Checked checkbox

Focused checked checkbox, before and after

Unchecked checkbox

Focused unchecked checkbox, before and after

Radio

Focused radio, before and after

Toggle switch

Focused toggle switch, before and after

Dropbutton item

Focused item in an open dropbutton, before and after

Views UI add display link

Focused add display link in Views UI, before and after

Media library item

Focused media library item, before and after

Media library remove icon link

Focused remove icon link on a media library item, before and after

Focus colour presets

Green

Green focus preset, before and after

Orange

Orange focus preset, before and after

Accent

Accent focus preset, before and after

Green, dark mode

Green focus preset in dark mode, before and after

gábor hojtsy’s picture

StatusFileSize
new17.44 KB
new19.63 KB
new19.65 KB

The views add button screenshot was showing an issue :) The Views tabs block in views-ui.pcss.css had an a:focus { outline: none; } covering every tab link. On main the Add link was the only one with a visible focus state, through its own box-shadow ring. The earlier change removed that ring and assumed the theme's default outline would take over, but this rule kept suppressing it, so the Add link ended up with nothing. Not this rule is removed. The default outline now reaches the Add link, as the new screenshots show, and as a side effect the display tabs themselves, such as "Page", also get a focus outline when tabbed to, which they never had before.

So a positive side effect as that these DID NOT have focus states before but now they do:

Views UI display tab, non-active

Focused non-active display tab in Views UI, before and after

Views UI display tab, active

Focused active display tab in Views UI, before and after

This was done again with LLM assistance.

gábor hojtsy’s picture

StatusFileSize
new252.13 KB
new16.05 KB
new10.03 KB

In #22 I mentioned my LLM had issues with the media dialog, figured that out and also filling in the missing screenshot for the node preview bar. I personally think these look good :)

Media library dialog, select checkbox

Focused select checkbox in the media library dialog, before and after

Node preview bar, back link

Focused back to content editing link in the node preview bar, before and after

Node preview bar, view mode select

Focused view mode select in the node preview bar, before and after

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

@gabor you rock with the perfect screenshots! That made reviewing so much easier. This looks good

  • catch committed d946182a on main
    fix: #3618140 Improve the accessibility of focus outlines
    
    By: kentr
    By...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Never feel confident when I open a CSS MR whether I'm going to feel competent enough to commit it or not, but this is another one where the resulting CSS is simpler than what it's replacing, and the screenshots and manual testing done on the issue make it clear it's doing what it's supposed to.

Committed/pushed to main, thanks!

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.

catch’s picture

Version: main » 11.x-dev
Status: Fixed » Patch (to be ported)

Got slightly over-excited here we need an 11.x backport MR.

  • mherchel committed 26c5498b on 11.x
    fix: #3618140 Improve the accessibility of focus outlines
    
    By: kentr
    By...
mherchel’s picture

Status: Patch (to be ported) » Fixed

Backported! Had to update StylesheetBytes in core/profiles/demo_umami/tests/src/FunctionalJavascript/MultipleRequestsPerformanceTestAssertions/umamiNodeAddEditor.yml

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.