Skip to content

The ref values doesn't work on theme.json block style variations since Gutenberg 18.7.0 #63159

@daviedR

Description

@daviedR

Description

After updating to Gutenberg 18.7.0 or Gutenberg 18.7.1, the ref values feature doesn't work on block style variations on theme.json. This works on the previous version Gutenberg 18.6.1.

** This issue also happens on WordPress 6.6 RC versions (without Gutenberg installed)

Step-by-step reproduction instructions

Copy this snippet to the theme.json.
We define the button element styling.
The normal core/button styling is inherited from the button element using ref values.
And then we want to change the outline button text color to use the button element's background color.

{
    "styles": {
        "elements": {
            "button": {
                "border": {
                    "color": "transparent",
                    "radius": "0.25em",
                    "style": "solid",
                    "width": "1px"
                },
                "color": {
                    "background": "var(--wp--preset--color--accent)",
                    "text": "var(--wp--preset--color--base)"
                },
                "spacing": {
                    "padding": {
                        "bottom": "0.5em",
                        "left": "1.25em",
                        "right": "1.25em",
                        "top": "0.5em"
                    }
                }
            }
        },
        "blocks": {
            "core/button": {
                "border": {
                    "color": { "ref": "styles.elements.button.border.color" },
                    "radius": { "ref": "styles.elements.button.border.radius" },
                    "style": { "ref": "styles.elements.button.border.style" },
                    "width": { "ref": "styles.elements.button.border.width" }
                },
                "color": {
                    "background": { "ref": "styles.elements.button.color.background" },
                    "text": { "ref": "styles.elements.button.color.text" }
                },
                "spacing": {
                    "padding": {
                        "bottom": { "ref": "styles.elements.button.spacing.padding.bottom" },
                        "left": { "ref": "styles.elements.button.spacing.padding.left" },
                        "right": { "ref": "styles.elements.button.spacing.padding.right" },
                        "top": { "ref": "styles.elements.button.spacing.padding.top" }
                    }
                },
                "variations": {
                    "outline": {
                        "border": {
                            "color": "currentColor",
                            "width": { "ref": "styles.elements.button.border.width" }
                        },
                        "color": {
                            "text": { "ref": "styles.elements.button.color.background" }
                        },
                        "spacing": {
                            "padding": {
                                "bottom": { "ref": "styles.elements.button.spacing.padding.bottom" },
                                "left": { "ref": "styles.elements.button.spacing.padding.left" },
                                "right": { "ref": "styles.elements.button.spacing.padding.right" },
                                "top": { "ref": "styles.elements.button.spacing.padding.top" },
                            }
                        }
                    }
                }
            }
        }
    }
}

Screenshots, screen recording, code snippet

Expected result:

image

Result of Gutenberg 18.7, the outline button has the same text color as the normal button. This means, the ref value on the outline style variation doesn't work.

image

Environment info

WordPress 6.5.5 + Gutenberg 18.7.1
or
WordPress 6.6 RC

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

Metadata

Metadata

Labels

[Status] In ProgressTracking issues with work in progress[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