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 spacingSizes do not work with the new padding presets UI #43234

Closed
richtabor opened this issue Aug 15, 2022 · 3 comments · Fixed by #43237
Closed

Theme.json spacingSizes do not work with the new padding presets UI #43234

richtabor opened this issue Aug 15, 2022 · 3 comments · Fixed by #43237
Assignees
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

@richtabor
Copy link
Member

richtabor commented Aug 15, 2022

Description

Originally reported in a comment on this issue, using spacingSizes within a theme.json file makes the new padding preset UI (recently merged #42173) not function properly.

The changes are applied, but the UI does not track the change.

Step-by-step reproduction instructions

Add spacing.spacingSizes to a theme.json file, as such:

"spacing": {
		"spacingSizes": [
			{
				"name": "50",
				"slug": "50",
				"size": "2rem"
			},
			{
				"name": "XL",
				"slug": "60",
				"size": "4rem"
			},
			{
				"name": "2XL",
				"slug": "70",
				"size": "clamp(2rem, 10vw, 20rem)"
			}
		]
}

See the stepped control not changing when dragging it.

Screenshots, screen recording, code snippet

184583776-68adf46f-7966-4048-8300-c111972f85ca

Environment info

WP 6.0.1
Gutenberg dev

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

@spencerfinnell
Copy link

I believe I ran in to a similar issue with the slug being defined as a string (which is what the schema says is correct), but working correctly when the slug is a number. Maybe a strict comparison somewhere?

@richtabor
Copy link
Member Author

I believe I ran in to a similar issue with the slug being defined as a string (which is what the schema says is correct), but working correctly when the slug is a number. Maybe a strict comparison somewhere?

Yup, that was it. Using a string doesn't work.

@glendaviesnz
Copy link
Contributor

glendaviesnz commented Aug 15, 2022

Thanks @richtabor and @spencerfinnell - I have a PR here to rectify this.

I will be putting up a dev note and additional documentation in the next few days ahead of the next GB release that will include this UI. This will outline the fact that ideally, the slugs should be in the format 10,20,30,40,50 ... with 50 representing the medium value, with the idea that we can more easily fallback to the nearest match of a spacing preset if a theme doesn't include one that is contained in copied block content ... but we can parse to ints at the point of needing to do that so have stuck with the more standard format of slugs being strings at other points in the code.

@glendaviesnz glendaviesnz self-assigned this Aug 16, 2022
@glendaviesnz glendaviesnz added 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 labels Aug 16, 2022
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 a pull request may close this issue.

3 participants