Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified default font size presets are not added to the resulting theme.json #707

Open
matiasbenedetto opened this issue Aug 23, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@matiasbenedetto
Copy link
Contributor

What?

Let's say you created a blank theme and modified the default font sizes to create your theme. If you save the theme, you expect those changes to be saved, but that isn't the case. The changes to the default font sizes are not saved in the theme.json, and the settings have been removed, so those changes are lost.

image

Expected

If the default font sizes were changed, they should be added to the theme.json file when the user saves, exports, or creates style variations.

Reproduction steps:

  1. Create a blank theme
  2. Edit the default font size presets.
  3. Save changes to the theme. You will see that the edited font sizes are not present in the resulting theme.json file and the default font sizes were reset to the default.
@eirichmond
Copy link
Contributor

I can confirm this behavior and explain why it happens.

By default, defaultFontSizes is set to true. This means the defaultFontSizes are sourced from Core or Global Styles if saved in the database.

When you create a blank theme, no fontSizes are defined in the theme.json file by default. This differs from other settings like settings.layout or settings.spacing.units, which are included by default. Additionally, defaultFontSizes remains true and is populated from Core.

When a user makes and saves changes via Global Styles, those changes are stored and read from the database, while defaultFontSizes continues to be true.

If the user saves changes back to the theme, the plugin processes defaultFontSizes: true, clears the database, and saves an empty settings.typography.fontSizes section back to the theme.json file. As a result, when revisiting Global Styles, the font size presets revert to the default values provided by Core.

Proposed Solution:

A potentially opinionated but effective solution is to always set defaultFontSizes: false and populate settings.typography.fontSizes with predefined sizes (e.g., small, medium, large, and x-large). This ensures that even when a blank theme is created, the presets will always be read from the theme.json file and saved back there when modified.

Alternatively, after creating a blank theme, you should manually set defaultFontSizes: false and define custom sizes for settings.typography.fontSizes (e.g., small, medium, large, and x-large) to maintain consistent behavior.

I've submitted a PR for this #749

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants