gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Global blockGap property is not overridable in style variations

Open EldarAgalarov opened this issue 1 year ago • 9 comments

Description

  1. 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"
		}
	}
}
  1. 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

EldarAgalarov avatar Oct 14 '25 10:10 EldarAgalarov

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.

github-actions[bot] avatar Nov 20 '25 00:11 github-actions[bot]

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

  1. Using a slightly modified variant of the proposed snippets to better display groups
  2. šŸž gap is not being overridden, but the background color is
  3. 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

  1. āœ… 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:

Image

SirLouen avatar Nov 27 '25 23:11 SirLouen

Is this issue still open and available to work on?

harshbhonsle avatar Jan 06 '26 11:01 harshbhonsle

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.

AtharvaSagane avatar Jan 10 '26 05:01 AtharvaSagane

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.

AtharvaSagane avatar Jan 10 '26 06:01 AtharvaSagane

Hi I would like to work on this issue is it avilable to work on.

BrajamohanDas-afk avatar Jan 10 '26 18:01 BrajamohanDas-afk

Hi! I’d like to work on this — is anyone assigned?

hrishikesh2810 avatar Jan 11 '26 08:01 hrishikesh2810

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 šŸ˜…

tellthemachines avatar Jan 12 '26 06:01 tellthemachines

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.

SirLouen avatar Jan 12 '26 12:01 SirLouen