Skip to content

Global styles don't support multi-value shorthand padding #40132

@tellthemachines

Description

@tellthemachines

Description

If a theme sets root padding in theme.json as a multi-value shorthand declaration, like so:

"styles": {
		"spacing": {
                        "padding": "68px 32px"
                }
	}

it gets added to the body as expected: padding: 68px 32px;.

But if a user then sets root padding in global styles, and if they don't provide a value for all sides (say they only want to change the left/right padding, and keep the theme's top/bottom value), the shorthand is interpreted as a single value and results in incorrect CSS:

padding-top: 68px 32px;
padding-right: 20px;
padding-bottom: 68px 32px;
padding-left: 20px;

Step-by-step reproduction instructions

  1. Activate Empty Theme, and replace the content of its theme.json with:
{
	"version": 2,
	"settings": {
		"appearanceTools": true,
		"layout": {
			"contentSize": "840px",
			"wideSize": "1100px"
		}
	},
	"styles": {
		"spacing": {
                        "padding": "68px 32px"
                }
	},
	"patterns": [ "short-text-surrounded-by-round-images", "partner-logos" ]
}
  1. In the Global Styles sidebar, under "Layout", change "Padding" by first clicking "Unlink sides" and then editing only one or two of the fields.
  2. Save and verify that incorrect CSS now appears attached to .editor-styles-wrapper in the editor, and body in the front end.

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.[Type] BugAn 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