Skip to content

Improve the admin bar focus style#12179

Open
afercia wants to merge 1 commit into
WordPress:trunkfrom
afercia:65445-admin-bar-focus
Open

Improve the admin bar focus style#12179
afercia wants to merge 1 commit into
WordPress:trunkfrom
afercia:65445-admin-bar-focus

Conversation

@afercia

@afercia afercia commented Jun 15, 2026

Copy link
Copy Markdown
Member

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

Use of AI Tools

None

This is a Proof Of Concept to improve the focus style on the admin bar.
See attached video recording to illustrate.
Comments on the Trac ticket.

Screen.Recording.2026-06-15.at.13.34.27.mov

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

Copy link
Copy Markdown

Hi there! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

@github-actions

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. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props afercia.

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

@github-actions

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.

#wpadminbar ul li:last-child .ab-item {
box-shadow: none;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be double checked. I have no idea why the last item in a menu was supposed to not use a box-shadow. Had to remove it otherwise the new focus style wouldn't work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some exploring, but I couldn't see any good reason for it, either. I thought it could be a leftover from some older styles, but couldn't find evidence of that. It's old; been there since at least 3.3.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know of a reason to keep it either (otherwise, the specificity could be reduced).

r19328 added the box-shadow rule(s).

  • At that time, admin-bar.dev.css only added a box-shadow for the flyout submenu containers and the shortlink input, neither of which would be an li element or have the .ab-item class.
  • I did not find any mention of this :last-child box-shadow on the six tickets referenced in the commit message. Images below comment 29 on ticket 18197 show a shadow on the W logo, which would not be the last item in a list. The admin-bar-show-right-border-with-custom-menu.diff patch has a :last-child selector, but that relates to the search input.
  • r26072 removed border-right: 0 but kept box-shadow: none.

@joedolson joedolson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of changes in here not strictly related to the focus styles (e.g., the fixed height of text in the profile menu), but IMO those are fine to include.

@sabernhardt sabernhardt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this overall, but it still should have a few changes.

background: none;
padding: 0;
height: 18px;
line-height: 1.38461538;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the line-height is good.

However, the height gave some space between the username and "Edit Profile" (if the username does not match the display name). To preserve that design, the span elements could have a min-height of 18px.

username with minimum height

If the separation is unimportant, at least the small line-height should be removed for narrower screens. The negative margin seems fine with "editor" as the username, but it is probably better to remove that for characters with descenders. (The screenshots below do not include a min-height.)

username with patch, and with other possible changes

outline-offset: -1px;
/* Only visible in Windows High Contrast mode */
outline: 2px solid transparent;
box-shadow: inset 0 -4px 0 0 currentColor;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The currentColor has a conflict on narrower screens for core links with icons attached to .ab-item::before. Removing the old rule should fix it.

mismatched color for focus shadow on some top-level links
  • r26134 added #999 for .ab-item in the 'my-sites' and 'site-name' nodes on small screens.
  • r36587, one of the commits that edited the color value, questioned why the color rule was necessary.
  • The colors.css stylesheets use #wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, so plugins such as "View Admin As" would display the correct color even though they have their icon on the ::before pseudo-element.
  • Yoast Duplicate Post defines #999 as the color, and that would need updating.

/* Only visible in Windows High Contrast mode */
outline: 2px solid transparent;
box-shadow: inset 0 -4px 0 0 currentColor;
transition: box-shadow .1s linear;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core is not perfectly consistent about the leading zero, but it is in the coding standards.

Suggested change
transition: box-shadow .1s linear;
transition: box-shadow 0.1s linear;

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.

3 participants