You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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:
Create a blank theme
Edit the default font size presets.
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.
The text was updated successfully, but these errors were encountered:
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.
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.
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:
The text was updated successfully, but these errors were encountered: