Skip to content

Toolbar: Fix missing focus style on the home icon in mobile layouts - #12780

Open
shamimmoeen wants to merge 2 commits into
WordPress:trunkfrom
shamimmoeen:fix/65765
Open

Toolbar: Fix missing focus style on the home icon in mobile layouts#12780
shamimmoeen wants to merge 2 commits into
WordPress:trunkfrom
shamimmoeen:fix/65765

Conversation

@shamimmoeen

Copy link
Copy Markdown

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

The home icon is drawn on .ab-item::before and has no nested .ab-icon span. In mobile layouts its resting colour is more specific than its focus colour, so focusing the link never changes the icon:

resting   #wpadminbar.mobile .quicklinks .ab-item:before   (1,3,1)
focus     #wpadminbar li .ab-item:focus:before             (1,2,2)

This adds a focus selector next to the existing .hover rule, at matching specificity (1,4,1).

Both files are needed. colors/_admin.scss generates the admin colour schemes. admin-bar.css handles the two cases that load no colour scheme file at all: the Fresh scheme, and the toolbar on the front end of the site.

Note

#wpadminbar only gets the mobile class when wp_is_mobile() returns true, so reproducing needs a device preset in DevTools or a real device — narrowing the browser window is not enough.

Screenshots

Before After
Admin admin-before admin-after
Front end frontend-before frontend-after

The front-end pair also shows the mechanism: site-name and site-editor draw their icons on .ab-item::before and gain a focus colour with the patch, while comments uses a nested .ab-icon and was already working.

Use of AI Tools

  • AI assistance: Yes
  • Tool(s): Claude Code
  • Model(s): Claude Opus 5
  • Used for: Investigating the CSS specificity conflict, verifying the behaviour across the admin colour schemes and the front-end toolbar, and drafting the commit message and this description. The final change was reduced, tested and confirmed by me.

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.

The home icon is drawn on `.ab-item::before` and has no nested `.ab-icon`
span. In mobile layouts its resting colour is more specific than its focus
colour, so focusing the link never changes the icon:

  resting   #wpadminbar.mobile .quicklinks .ab-item:before   (1,3,1)
  focus     #wpadminbar li .ab-item:focus:before             (1,2,2)

Add a focus selector next to the existing `.hover` rule, at matching
specificity (1,4,1).

Both files are needed. `colors/_admin.scss` generates the admin colour schemes.
`admin-bar.css` handles the two cases that load no colour scheme file at all:
the Fresh scheme, and the toolbar on the front end of the site.

See https://core.trac.wordpress.org/ticket/65765
@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 shamimmoeen.

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.

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.

1 participant