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

theme.json schema change for spacingScale.steps warns about valid value 0 #62561

Closed
mrwweb opened this issue Jun 13, 2024 · 3 comments
Closed
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended

Comments

@mrwweb
Copy link

mrwweb commented Jun 13, 2024

Description

The documented way to turn off the spacing scale (see "Disable the spacing scale" section) is to set settings.spacing.spacingScale.steps to 0.

In VS Code, that now produces the warning:

Value is below the minimum of 1.

I don't think it's directly relevant, but the recently filed #62520 is also about changes to theme.json schema impacting valid spacing values.

Step-by-step reproduction instructions

  1. Create a theme.json file
  2. Use the following value and observe a warning for the value "0" on line 7 in VS Code
{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 2,
	"settings": {
		"spacing": {
			"spacingScale": {
				"steps": 0
			}
		}
	}
}

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.5
  • No Gutenberg
  • Custom hybrid theme
  • VS Code

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

Yes

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

No

@mrwweb mrwweb added the [Type] Bug An existing feature does not function as intended label Jun 13, 2024
@jordesign jordesign added [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Feature] Layout Layout block support, its UI controls, and style output. labels Jun 14, 2024
@ajlende
Copy link
Contributor

ajlende commented Jun 14, 2024

I see you're using the trunk version of the $schema which includes the nightly changes to theme.json and only supports the latest version. It's much better to match your schema version with the minimum supported WordPress version to be alerted of features that might not be available for your users. For example, you would use https://schemas.wp.org/wp/6.5/theme.json if your theme's minimum supported version is WordPress 6.5.

The minimum value for steps has changed in theme.json version 3 which is introduced in WordPress 6.6. The correct way to disable spacingScale is to set settings.spacing.defaultSpacingScale to false in version 3.

When your minimum version reaches 6.6, there is a migration guide for theme.json version 3.

@ajlende ajlende closed this as completed Jun 14, 2024
@mrwweb
Copy link
Author

mrwweb commented Jun 14, 2024

@ajlende Thanks for that info. I'm glad to about the migration guide. I wonder if the schema could flag the steps: 0 with an explicit mention of defaultSpacingSizes: false. (updated to fix wrong property name, props @crankysparrow)

@michelleenos
Copy link

michelleenos commented Jul 16, 2024

In case anyone else comes here looking for this -

{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 3,
	"settings": {
		"spacing": {
	          	"spacingSizes": [
				...
            		],
			"defaultSpacingSizes": false,
		}
	}
}

The comment above indicated the setting to be defaultSpacingScale which didn't work for me, but got me on the right track with the migration guide. Setting defaultSpacingSizes to false did the trick!

This is working for me on WordPress 6.6, with both the trunk version of the schema and https://schemas.wp.org/wp/6.6/theme.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants