Repository navigation
Theme.json schema: allow spacing margin/padding to be defined as sides - #79653
gunjanjaswal wants to merge 2 commits into
Conversation
settings.spacing.margin and settings.spacing.padding can be a boolean, an array of sides, or an object with a `sides` array. The dimensions panel already reads all three (the Array.isArray checks in dimensions-panel.js), but the schema only allowed boolean, so a valid theme.json using side arrays was flagged as invalid in editors. Update the schema to accept the three shapes, regenerate the theme.json reference docs, and add an integration fixture covering the array and object forms. Fixes WordPress#79628.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
1 similar comment
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @gunjanjaswal! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
The two red checks look unrelated to this change (schema + generated docs + a test fixture):
The schema test ( |
|
Friendly bump on this — it's been open a while without a first look. It's a small, self-contained schema change: letting |
|
Circling back on this. The "Required changes from trunk" check just means the branch has drifted behind trunk since the summer — I'm glad to rebase it clean the moment a reviewer's ready to take a look. The change itself is small and self-contained: allow theme.json spacing |
Fixes #79628.
In the theme.json schema,
settings.spacing.marginandsettings.spacing.paddingonly allowed a boolean, but the editor actually takes more than that. It also accepts an array of sides like[ "top", "bottom" ], or an object with asidesarray. You can see it inpackages/block-editor/src/components/global-styles/dimensions-panel.js, where the sides get read like this:So boolean, array, and
{ sides }all work fine at runtime, but the schema only ever described the boolean. Anyone using side arrays got bogus validation errors, and the generated reference docs were off too.The fix is just to widen the schema. In
schemas/json/theme.json,marginandpaddingnow use aoneOfof a boolean, an array of side strings (top/right/bottom/left/horizontal/vertical), or an object with asidesarray. I regenerateddocs/reference-guides/theme-json-reference/theme-json-living.mdwithnpm run docs:theme-ref, and added a fixture attest/integration/fixtures/theme-json-spacing-sides/theme.jsoncovering the array and object forms, whichtest/integration/theme-schema.test.jsvalidates. I left this scoped tomarginandpaddingsince that's what the issue's about, butblockGapreads the same way, so it'd be an easy follow-up if you want it.To check it:
npm run test:unit test/integration/theme-schema.test.js. Or setsettings.spacing.paddingto[ "top", "bottom" ]in a theme.json and open it in a schema-aware editor, and it shouldn't flag an error anymore.Use of AI Tools
This PR was written with AI assistance (Claude Code). I reviewed, tested, and understand every change, and I take responsibility for it.