Strip null values from styles when saving to theme.json
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, php
- Domain
- backend
Research direction
Start with CBT_Theme_JSON_Resolver::export_theme_data( 'all' ) in the plugin's PHP, where the global styles are assembled before being written to theme.json, and find the point where styles.blocks is built. Check that the null-stripping also covers style variations. Done when exporting the core/quote border example from the issue produces no null keys in theme.json.
Written by the indexing model from the issue text.
Description
Description
When the user's global styles contain null values, "Save Changes to Theme" writes them into theme.json as they are. The theme.json schema rejects null here, and WordPress ignores these keys, so they're only noise that theme authors have to remove by hand.
The editor currently saves such nulls when border sides are unlinked in Global Styles (WordPress/gutenberg#84814), for example:
"core/quote": {
"border": {
"color": null,
"style": null,
"width": null,
"left": { "color": "currentColor", "style": "solid", "width": "4px" }
}
}
Steps to reproduce
- Activate Twenty Twenty-Five with Create Block Theme.
- Site Editor → Styles → Blocks → Quote → Borders: click "Unlink sides", set the left width to
4px, save. - Save Changes to Theme (or call
CBT_Theme_JSON_Resolver::export_theme_data( 'all' )).
Expected
null values are dropped from the exported theme.json (and style variations).
Actual
styles.blocks["core/quote"].border in the export has "color":null, "style":null and "width":null.
Environment
- Create Block Theme 2.10.2
- WordPress 7.1.3, Gutenberg 24.2.0
Drafted with AI assistance, reproduced and verified by me.
- Dominant language
- JavaScript
- Stars
- 424
- Forks
- 69
- Avg merge
- 18h 59m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WordPress/create-block-theme
-
Style variations are saved without $schemaPossibly taken @KhushalSainS claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
WordPress/create-block-theme#886 · 1 reaction ·
Maintainers usually reply within 2 days
-
Localize Text wraps empty block attribute values in a translation callPossibly taken @ishitaj34 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
WordPress/create-block-theme#879 ·
Maintainers usually reply within 2 days
-
Generated pattern headers use the template slug as title and category names instead of slugsPossibly taken @ishitaj34 claimed this 15 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
WordPress/create-block-theme#871 · 1 comment ·
Maintainers usually reply within 2 days
-
Localize Text skips text that starts or ends on a new linePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
WordPress/create-block-theme#868 ·
Maintainers usually reply within 2 days
-
Localize Text skips Accordion headingsPossibly taken @kushagra-goyal-14 claimed this 20 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
WordPress/create-block-theme#867 ·
Maintainers usually reply within 2 days
All issues in WordPress/create-block-theme
Similar issues
-
BUG
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
type/bug
Difficulty 1/5 Under an hour Newbie friendliness 75/100
flarum/framework#5231 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/rocketmq-dashboard#6896 ·
Maintainers usually reply within 3 days
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
[workshop-sync] workshop/side-quest-17-06-output-injection.md: stale add_comment.cjs line referencesOpendocumentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
githubnext/gh-aw-workshop#4679 ·
Maintainers usually reply within 1 day