Global blockGap property is not overridable in style variations
Description
- Define global blockGap property in theme.json:
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 3,
"settings": {
"spacing": {
"blockGap": true
}
},
"styles": {
"spacing": {
"blockGap": "10px"
}
}
}
- Create style variation for any block that override blockGap:
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 3,
"title": "No Block Gap",
"slug": "no-block-gap",
"blockTypes": ["core/group"],
"styles": {
"spacing": {
"blockGap": "0"
}
}
}
Override doesn't work. Workaround:
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 3,
"title": "No Block Gap",
"slug": "no-block-gap",
"blockTypes": ["core/group"],
"styles": {
"css": "&.is-layout-constrained > *:not(:first-child) { margin-block-start: 0; }"
}
}
UPD. Same issue
Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.
Reproduction Report
Description
ā This report validates that the issue can be reproduced.
Environment
- WordPress: 6.8.3
- PHP: 8.3.28-dev
- Server: PHP.wasm
- Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.40.1)
- Browser: Chrome 142.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.3
- MU Plugins: None activated
- Plugins:
- Gutenberg 22.2.0-rc.1
- Test Reports 1.2.1
Testing Instructions
- Using a slightly modified variant of the proposed snippets to better display groups
- š gap is not being overridden, but the background color is
- Result below
Playground Testing URL
https://playground.wordpress.net/?blueprint-url=https%3A%2F%2Fgist.githubusercontent.com%2FSirLouen%2F25c154288850e1b5231bfc161c595f78%2Fraw%2Fc75a37cd19fb76e71ba8bbfef663a955c851d5da%2Fblueprint.json
Actual Results
- ā Error condition occurs (reproduced).
Supplemental Artifacts
theme.json
{
"schema": "https:\/\/schemas.wp.org\/trunk\/theme.json",
"version": 3,
"settings": {
"spacing": {
"blockGap": true
},
"color": {
"background": true
}
},
"styles": {
"spacing": {
"blockGap": "50px"
}
"color": {
"background": "#00ff00"
}
}
}
styles/no-block-gap-json
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 3,
"title": "No Block Gap",
"slug": "no-block-gap",
"blockTypes": ["core/group"],
"styles": {
"spacing": {
"blockGap": "0"
},
"color": {
"background": "#ff0000"
}
}
}
Result:
Is this issue still open and available to work on?
Hi! I would like to work on this issue if it is still available.
Reproduction report reviewed. Next step will be to investigate why the variant styles' value for blockGap isn't overriding the global value.
I will create PR with findings or proposed fix.
The issue is not CSS specificity. Layout spacing (blockGap) is resolved before block style variations are applied. As a result, layout styles always use the global blockGap, ignoring block-level variation overrides.
The layout engine should resolve blockGap in this order: variation ā block ā global.
Hi I would like to work on this issue is it avilable to work on.
Hi! Iād like to work on this ā is anyone assigned?
I don't believe this is right for "Good first issue" so I've removed the label. Like most layout and style variation problems, it's a bit of a rabbit hole š
I don't believe this is right for "Good first issue" so I've removed the label. Like most layout and style variation problems, it's a bit of a rabbit hole š
True, this was set before when Needs Dev was unclear.