Skip to content

Spacer block bug retrieving spacing.spacingSizes presets. #54084

Open

Description

Description

Before 6.3 update, I used the spacer block with 4 block variations for preset sizes (with a js filter). But, when I updated to 6.3 it showed the spacing.spacingSizes that I had specified for gaps & margin! Super nice!

I was very happy to see that these are now used for the spacer block. At least... I thought so. Because, after I removed all the variations and worked on some other things, the spacer presets are gone again.

For some reason, the spacer blocks that existed before 6.2 and after updating to 6.3 did have the presets. But, adding a new spacer block does not have the presets.

Looking at the source code of the block I see that spacing.spacingSizes is actually retrieved.

https://github.com/WordPress/gutenberg/blob/1c09fae498d2bf073975454d66a4c89bc3ede8d8/packages/block-library/src/spacer/controls.js#L28C1-L28C60

But somehow they are not working! I have tried setting the spacingSizes specifically on settings.blocks.core/spacer

This is how I load variables in theme.json (the supplied var(--spacing--token--1) are processed with media queries, this has never given me issues before).

"spacing": {
       "blockGap": true,
	"units": [
		"%",
		"px",
		"rem"
	],
	"customSpacingSize": false,
	"spacingScale": {
		"steps": 0
	},
	"spacingSizes": [
		{
			"size": "var(--spacing--token--1)",
			"slug": "1",
			"name": "1"
		},
		{
			"size": "var(--spacing--token--2)",
			"slug": "2",
			"name": "2"
		},
		{
			"size": "var(--spacing--token--3)",
			"slug": "3",
			"name": "3"
		},
		{
			"size": "var(--spacing--token--4)",
			"slug": "4",
			"name": "4"
		},
		{
			"size": "var(--spacing--token--5)",
			"slug": "5",
			"name": "5"
		}
	]
  }

Step-by-step reproduction instructions

I suppose:

  • Add spacer blocks to a WP 6.2 site
  • Add settings.spacing.spacingSizes (2-3 presets will do)
  • Inspect the spacer blocks (no preset tokens)
  • Update WP to 6.3
  • Inspect the spacer blocks (do they have preset tokens or not?) -- in my case YES
  • Remove the spacer block. Add a new one.
  • Inspect the spacer blocks (do they have preset tokens or not?) -- in my case NO

Screenshots, screen recording, code snippet

Edit: I found another theme that was still in 6.2 and can now demonstrate this weird behavior, just after update to 6.3:

wp_spacer_presets

Environment info

  • WordPress 6.3(.1)
  • No gutenberg plugin
  • Default TT3 theme with customized theme.json

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    [Block] SpacerAffects the Spacer BlockAffects the Spacer Block[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions