close
Skip to content

Fix: Default option of Font Appearance in Typography Panel#70966

Open
Debarghya-Banerjee wants to merge 1 commit intoWordPress:trunkfrom
Debarghya-Banerjee:fix-70938/default-font-appearance-in-typography-panel
Open

Fix: Default option of Font Appearance in Typography Panel#70966
Debarghya-Banerjee wants to merge 1 commit intoWordPress:trunkfrom
Debarghya-Banerjee:fix-70938/default-font-appearance-in-typography-panel

Conversation

@Debarghya-Banerjee
Copy link
Copy Markdown
Contributor

@Debarghya-Banerjee Debarghya-Banerjee commented Jul 29, 2025

What?

Closes #70938

Fixes the issue where resetting typography and selecting Default from the Font Appearance dropdown in the Site Editor was not possible.

Why?

The previous solution used a useEffect that ran on changes to nearestFontStyle and nearestFontWeight only. It updated or reset font appearance regardless of whether the font family changed or if the user had explicitly set font style or weight. This caused:

  • Unwanted resets or overwrites of user choices.
  • Incorrect behaviour when selecting Default, as the default value (undefined) was not handled properly.
  • Font appearance being stuck or falling back unexpectedly.

How?

  • Introduced a useRef to track the previous font family, allowing the effect to only run when the font family actually changes.
  • Added logic to check if the user has explicitly set font style or weight, preventing unintended overrides.
  • When the font family changes and there is no explicit font appearance set, the nearest valid font style and weight are applied.
  • If no valid styles or weights are available for the new font family, the font appearance is reset cleanly.

@Debarghya-Banerjee Debarghya-Banerjee changed the title Fix Default option of Font Appearance in Typography Panel Fix: Default option of Font Appearance in Typography Panel Jul 29, 2025
@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: Debarghya-Banerjee <debarghyabanerjee@git.wordpress.org>

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

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't reset typography in Elements of the site editor

2 participants