Skip to content

Font Library: keep deactivated theme font variants listed - #82091

Open
Mayank-Tripathi32 wants to merge 4 commits into
WordPress:trunkfrom
Mayank-Tripathi32:fix/60392-font-library-theme-font-deactivate
Open

Mayank-Tripathi32 wants to merge 4 commits into
WordPress:trunkfrom
Mayank-Tripathi32:fix/60392-font-library-theme-font-deactivate

Conversation

@Mayank-Tripathi32

@Mayank-Tripathi32 Mayank-Tripathi32 commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Fixes #60392

What?

Keep deactivated theme font variants listed in the Font Library so they can be activated again. Deactivating every variant no longer removes the family from the modal, and the family card counts the variants the theme ships rather than only the activated ones.

Why?

Deactivating a variant removes it from the user's global styles, and both the details-view lookup and the list merge only considered the activated fonts. Unchecking a variant and saving made its row disappear, with no way to re-activate it, and left the card reporting e.g. "2 of 2 active" for a font the theme ships three variants of.

Worth noting for testers: this only reproduces when a strict subset of a multi-variant font is deactivated and the change is saved (Update) before reopening. Deactivating the only variant, or all of them. removes the family from the user's global styles entirely and the base-fonts fallback brings everything back, so single-variant fonts (which most variable fonts are) never show it. Reproduced on current trunk and on WordPress Playground (WP stable) with TT4's Cardo, which ships three variants.

How?

Look theme fonts up in the theme's own (base origin) font families merged with the activated ones, using mergeFontFamilies so families are merged at the variant level, both when selecting a font for the details view and when building the Library list. Merging rather than replacing keeps fonts that only an applied style variation defines, which is the constraint described in #60392 (comment).

Testing Instructions

  1. With Twenty Twenty-Four active, open the Site editor → Styles → Typography → Manage fonts.
  2. Click Cardo, uncheck one variant (e.g. Cardo Normal Italic), click Update, and close the modal.
  3. Reopen Manage fonts → Cardo: the unchecked variant is still listed and can be re-activated, and the card reads "2 of 3 active".
  4. Also uncheck all three variants and update: the family stays in the list.

On trunk, step 3 shows only two rows and the deactivated variant cannot be restored from the UI.

AI Disclosure?

  • Yes, Used to test & investigate. Claude Opus/Fable

Before

60392-before-trunk.webm

After

60392-after-fix.webm

The font details view renders one row per entry in the selected font's
fontFace array, while each row's checkbox state is derived separately
from the activated fonts. Deactivating a variant removes it from the
user's global styles, so looking the selected theme font up in the
activated list meant the row for a deactivated variant disappeared and
could never be re-checked. Deactivating every variant dropped the whole
family.

Look theme fonts up in the theme's own font families merged with the
activated ones, mirroring what installed-fonts already does for the
list. Merging rather than replacing keeps fonts that only an applied
style variation defines.
The list concatenated only the families missing from the user's global
styles, so a family with some variants deactivated kept its shrunken
user entry and the card reported '2 of 2 active' for a font the theme
ships three variants of. Use the same variant-level merge the details
view now uses, so the card counts what the theme offers.
@Mayank-Tripathi32
Mayank-Tripathi32 marked this pull request as ready for review August 26, 2026 19:53
@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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mayank-Tripathi32 <mayanktripathi32@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: matiasbenedetto <mmaattiiaass@git.wordpress.org>
Co-authored-by: creativecoder <grantmkin@git.wordpress.org>

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

@Mayank-Tripathi32
Mayank-Tripathi32 requested a balanced review from Copilot August 26, 2026 19:54
@Mayank-Tripathi32 Mayank-Tripathi32 added the [Type] Bug An existing feature does not function as intended label Aug 26, 2026

Copilot AI 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.

Pull request overview

Keeps deactivated theme font variants available in the Font Library for reactivation.

Changes:

  • Merges base and active theme fonts at the variant level.
  • Uses merged fonts for details and accurate active-variant counts.
  • Documents the fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
installed-fonts.tsx Lists and counts all theme variants.
context.tsx Selects fonts from merged theme data.
CHANGELOG.md Records the bug fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

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

Labels

[Feature] Font Library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deactivating a theme font removes it from the Font Library

3 participants