Skip to content

Dynamic references in theme.json are not resolved in the site editor #42890

@oandregal

Description

@oandregal

Description

We've introduced a new mechanism to refer to a different style dynamically at #41696 which allows us to do things such as:

"styles": {
    "color": {
        "background": { "ref": "styles.color.text" },
        "text": "yellow"
    }
}

In the example, the result would be that the text and background colors are the same (yellow).

Captura de ecrã de 2022-08-02 12-29-40

While this works in the front-end it doesn't in the site editor:

  • the styles box does not render the background
  • the color tools do not render the background
  • the site editor breaks if the user tries to edit the background color
Styles Color tools Site editor
Captura de ecrã de 2022-08-02 12-28-19 Captura de ecrã de 2022-08-02 12-28-28 Captura de ecrã de 2022-08-02 12-28-36

Step-by-step reproduction instructions

  • Use TwentyTwentyTwo theme and update the styles.color values to be:
"background": { "ref": "styles.color.text" },
"text": "yellow"
  • Go to the front-end and verify that it works as expected.
  • Go to the site editor and open the Global Styles Toolbar. Click on Colors and then in the Backgound element. It'll throw an error.

Environment info

I can reproduce this is trunk.

Metadata

Metadata

Assignees

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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions