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

Large list of spacing sizes causes var:preset|spacing|default value for other dimensions #52976

Closed
wongjn opened this issue Jul 26, 2023 · 0 comments · Fixed by #53005
Closed
Assignees
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Package] Style Engine /packages/style-engine [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@wongjn
Copy link

wongjn commented Jul 26, 2023

Description

If a theme has more than 8 spacing size presets, when customizing a dimension for margin, padding or block gap in the block editor for a block, the other non-customized dimensions for that "dimension group" will have a value of var:preset|spacing|default which for most themes will not exist.

8 is the threshold for whether <SpacingInputControl> displays a range control or a dropdown control:

https://github.com/WordPress/gutenberg/blob/v16.1.2/packages/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js#L60

It seems likely then that it could be a bug with the way the dropdown control is used to handle the default value.

Step-by-step reproduction instructions

  1. Edit wp-content/themes/twentytwentythree/theme.json to add 3 extra members in settings.spacing.spacingSizes:
    		"slug": "80",
    		"name": "6"
    +	},
    +	{
    +		"size": "1rem",
    +		"slug": "foo",
    +		"name": "foo"
    +	},
    +	{
    +		"size": "2rem",
    +		"slug": "bar",
    +		"name": "bar"
    +	},
    +	{
    +		"size": "3rem",
    +		"slug": "baz",
    +		"name": "baz"
     	}
     ],
     "units": [
     	"%",
  2. Enable Twenty Twenty-Three theme.
  3. Go into the Site Editor and edit the Footer template part.
  4. Edit the top padding of the top level core/group block.
  5. See that the left and right dimensions now lose their global padding and instead have the invalid var:preset|spacing|default value.

Screenshots, screen recording, code snippet

✅ With 8 or less spacing sizes

image

The other padding dimensions are not set when editing the top padding (commented formatted for readability):

<!-- wp:group {
  "style":{
    "spacing":{
      "padding":{
        "top":"var:preset|spacing|40"
      }
    }
  },
  "layout":{"type":"constrained"}
} -->

❌ With more than 9 spacing sizes

image

The other padding dimensions are set to var:preset|spacing|default when editing the top padding (commented formatted for readability):

<!-- wp:group {
  "style":{
    "spacing":{
      "padding":{
        "top":"var:preset|spacing|40",
        "right":"var:preset|spacing|default",
        "bottom":"var:preset|spacing|default",
        "left":"var:preset|spacing|default"
      }
    }
  },
  "layout":{"type":"constrained"}
} -->

Environment info

WordPress 6.3-RC2-56310

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 Needs Testing Needs further testing to be confirmed. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Package] Style Engine /packages/style-engine [Type] Bug An existing feature does not function as intended labels Jul 26, 2023
@glendaviesnz glendaviesnz self-assigned this Jul 27, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jul 27, 2023
@glendaviesnz glendaviesnz removed the Needs Testing Needs further testing to be confirmed. label Jul 27, 2023
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 [Package] Style Engine /packages/style-engine [Status] In Progress Tracking issues with work in progress [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