Skip to content

The gap control breaks theme.json block gap when using nested CSS var() fallback. #76896

@inc2734

Description

@inc2734

Description

When styles.spacing.blockGap in theme.json uses a nested CSS variable with fallback, adjusting the column-gap or row-gap control produces invalid CSS.

Step-by-step reproduction instructions

  1. Install WordPress 7.0 beta2 (or RC2)
  2. Modify TT5 theme.json:
{
  "styles": {
    "spacing": {
      "blockGap": "var(--a, var(--b, 1.2rem))"
    }
  }
}
  1. Ensure styles.spacing.blocks.core/columns is not set
  2. Insert a Columns block
  3. Confirm initial gap is correctly applied:
gap: var(--a, var(--b, 1.2rem));
  1. Adjust column-gap using the block settings UI

Screenshots, screen recording, code snippet

column-gap not set:
Image

Column gap is configured:
Image

The resulting CSS should remain valid, e.g.:

gap: var(--a, var(--b, 1.2rem)) var(--wp--preset--spacing--40);

The generated CSS becomes invalid, for example:

gap: var(--b, var(--wp--preset--spacing--40)
  • The outer var() is partially lost
  • Parentheses become unbalanced
  • Resulting CSS is syntactically broken

Environment info

  • WordPress 7.0 RC2

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions