Skip to content

Make outlier focus styles follow the 2px focus rule. - #15683

Open
sxecurify wants to merge 1 commit into
WordPress:trunkfrom
sxecurify:fix/65878
Open

sxecurify wants to merge 1 commit into
WordPress:trunkfrom
sxecurify:fix/65878

Conversation

@sxecurify

Copy link
Copy Markdown

https://core.trac.wordpress.org/ticket/65878

This is a first step toward a consistent 2 CSS pixel focus indicator across the admin. It only fixes the outlier rules listed in the ticket comments, so the approach can be reviewed on a small diff before the full sweep.

The rule being proposed

  • Elements with a border: the 1px border changes to the theme color, plus box-shadow: 0 0 0 1px var(--wp-admin-theme-color). Total: 2px.
  • Elements without a border: box-shadow: 0 0 0 2px var(--wp-admin-theme-color). Total: 2px.
  • Core focus styles stop using --wp-admin-border-width-focus. It resolves to 1.5px on high-DPI screens, which is thinner than the native 2px focus style and matches the icon stroke width.

Changes

  • .wrap .page-title-action:focus (common.css): replaced the hardcoded #3582c4 with --wp-admin-theme-color, so the focus color follows the admin color scheme.
  • .wrap .page-title-action:focus (colors/_admin.scss): changed the box-shadow from --wp-admin-border-width-focus to 1px. The button now shows a 2px ring whether or not a color scheme stylesheet loads. Before, it was 2px without one and 2.5–3px with one.
  • .customize-control .attachment-media-view .button-add-media:focus (customize-controls.css): replaced #3582c4 with --wp-admin-theme-color.
  • .media-widget-control .attachment-media-view .button-add-media:focus (widgets.css): replaced the old blurred 0 0 3px glow in #4f94d4 with a 1px theme-colored border plus a 1px shadow.

.login .button.wp-hide-pw:focus and .imgedit-help-toggle:focus (media.css, media-views.css) already follow the rule and are unchanged.

Only the source files are changed. The -rtl.css and .min.css files are generated during the build.

Testing instructions

Test on a standard display and a 2x (high-DPI) display. Move focus with the Tab key. Measure the ring in screen pixels or a zoomed screenshot; devtools may not show the real thickness.

  1. Posts → All Posts: Tab to Add New Post next to the page title. The ring should be 2px in the theme color.
  2. Users → Profile: switch the admin color scheme to Midnight and repeat step 1. The ring should be red, not blue.
  3. Appearance → Customize → Site Identity: Tab to the Select site icon button. The ring should be 2px in the theme color.
  4. Appearance → Widgets (classic widgets, e.g. with the Classic Widgets plugin): add an Image widget and Tab to Add Image. The ring should be a solid 2px ring with no blur.
  5. Repeat steps 3 and 4 with the Midnight color scheme.

Next steps (not in this PR)

  • Apply the rule to the other Core focus styles: about 58 uses of --wp-admin-border-width-focus across 21 source files, plus colors/_admin.scss and colors/_mixins.scss.
  • Other legacy glow focus styles: .wp-color-result:focus (color-picker.css), .ui-button:focus (jquery-ui-dialog.css), .mce-window .mce-btn:focus (editor.css) and .background-position-control input[type="radio"]:focus ~ .button (themes.css).
  • The Editor side needs a change to --wp-admin-border-width-focus in Gutenberg (@wordpress/base-styles).

Trac ticket: https://core.trac.wordpress.org/ticket/65878

Use of AI Tools

AI assistance: Yes
Tool(s): Kiro
Model(s): Claude Opus 5.5
Used for: Auditing the focus rules in the admin CSS, drafting the CSS changes, the commit message and this description. I reviewed every change and tested it in the browser.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @ThaDeKur.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants