Skip to content

Editor: Restore contrast of active TinyMCE toolbar button icons - #12783

Open
itzmekhokan wants to merge 1 commit into
WordPress:trunkfrom
itzmekhokan:fix/65768-tinymce-active-button-icon-color
Open

Editor: Restore contrast of active TinyMCE toolbar button icons#12783
itzmekhokan wants to merge 1 commit into
WordPress:trunkfrom
itzmekhokan:fix/65768-tinymce-active-button-icon-color

Conversation

@itzmekhokan

Copy link
Copy Markdown

TinyMCE's lightgray skin styles active toolbar buttons as white icons on a dark background. editor.css overrides both halves — the background becomes light gray and the icon colour reverts to inherit — but the colour override used the same selectors as the skin, so it only won the cascade when parsed later.

What the problem was:

  • TinyMCE appends its skin stylesheet when the editor initializes. When the editor is initialized after page load, as the Classic block does, the skin is parsed after editor.css and its white icon colour wins the tie.
  • The classic editor is unaffected because wp_editor() prints editor-buttons inline in the body, after the skin.
  • Result: active buttons render a white icon on the #f0f0f1 background — 1.1:1 contrast.

What the fix does:

  • Adds the mce-widget class, which TinyMCE puts on every button alongside mce-btn, to the five existing override selectors.

Approach and why:

  • The override already expresses the correct intent; it just needed to stop depending on source order. Adding a class TinyMCE always emits raises specificity above the skin without narrowing scope.
  • Scoping to .mce-toolbar .mce-btn-group would also have worked but would drop menubar buttons, which plugins can enable via tiny_mce_before_init.

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

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Ticket analysis, tests and writing PR. All changes were reviewed and validated 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.

TinyMCE's lightgray skin styles active toolbar buttons as white icons
on a dark background, and this file overrides both halves of that: the
background becomes light gray, and the icon colour reverts to `inherit`.
The colour override used the same selectors as the skin, so it only won
the cascade when it was parsed later.

TinyMCE appends its skin stylesheet when the editor initializes. When
the editor is initialized after page load, as the Classic block does,
the skin is parsed after this file and its white icon colour wins,
leaving the icons all but invisible on the light gray background.

Add the `mce-widget` class, which TinyMCE puts on every button
alongside `mce-btn`, to the override so it wins on specificity instead
of source order.

Fixes #65768.
@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 khokansardar.

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