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

Exported theme.json includes empty collections #53199

Closed
pbking opened this issue Jul 31, 2023 · 2 comments
Closed

Exported theme.json includes empty collections #53199

pbking opened this issue Jul 31, 2023 · 2 comments
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

Comments

@pbking
Copy link
Contributor

pbking commented Jul 31, 2023

Description

When the theme is exported (either via the 'Export Theme' menu item in the site editor or via a plugin such as Create Block Theme which calls WP_Theme_JSON_Gutenberg() ) the theme.json file includes values that are unnecessary.

Some of these values include default values which shouldn't be included in the theme.json files.

Most agregious, however, are a number of empty collections. These are mentioned in more detail in this Create Block Theme issue. In short, the inclusion of the spacingSizes:[] collection causes the Site Editor to NOT show the default spacing sizes to the user.

Other empty collections (such as colors) don't seem to negatively impact the user's experience but probably shouldn't be included in the export.

Other values (such as settings.color.background:true) are default values and shouldn't be exported in the theme.json file.

Step-by-step reproduction instructions

Create a 'blank' theme. (Using Create Block Theme is helpful for this.)
Make a small change to the theme (for example changing the content width).
Export the theme and observe the theme.json values.
Note the inclusion of empty collections as well as default values which should be excluded from the export.

Screenshots, screen recording, code snippet

No response

Environment info

  • Wordpress 6.2.2
  • Gutenberg 16.3

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@jordesign jordesign added [Type] Bug An existing feature does not function as intended [Package] Style Engine /packages/style-engine labels Aug 1, 2023
@ramonjd ramonjd added Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json and removed [Package] Style Engine /packages/style-engine labels Aug 8, 2023
@jorgefilipecosta
Copy link
Member

jorgefilipecosta commented Aug 17, 2023

I replicated the issue, indeed upon inspecting the database after a simple change to a blank theme, there are numerous unnecessary and unexpected elements stored. The issue doesn't occur, for instance, when altering one of the default themes; it necessitates a change from the "blank theme". Take, for example, a theme with the subsequent theme.json:

{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"settings": {
		"appearanceTools": true,
		"layout": {
			"contentSize": "620px",
			"wideSize": "1000px"
		},
		"spacing": {
			"units": [ "%", "px", "em", "rem", "vh", "vw" ]
		},
		"typography": {
			"fontFamilies": [
				{
					"fontFamily": "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif",
					"name": "System Font",
					"slug": "system-font"
				}
			]
		},
		"useRootPaddingAwareAlignments": true
	},
	"templateParts": [
		{
			"area": "header",
			"name": "header"
		},
		{
			"area": "footer",
			"name": "footer"
		}
	],
	"version": 2
}

@youknowriad
Copy link
Contributor

I think this is a duplicate of #53199 which I'm fixing on #54500

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

No branches or pull requests

5 participants