gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Site Editing: missing global inline styles

Open Sandstromer opened this issue 5 years ago • 7 comments

Description

Since 9.9.0 with the using the new theme.json structure, on the front end, the global-styles-inline-css is missing styles such as has-x-color and has-x-background-color

Not sure if this is a bug or intentional.

If not a bug, is it now expected that themes need to take account of this by including all missing styles (that were previously loaded inline by Gutenberg) in their stylesheet?

WordPress information

  • WordPress version: 5.6.1
  • Gutenberg version: 9.9.0
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? No. Testing emptytheme using new theme.json structure.

Sandstromer avatar Feb 05 '21 11:02 Sandstromer

There is a breaking change in the experimental-theme.json, see https://make.wordpress.org/themes/2021/02/04/gutenberg-9-9-new-json-structure-for-theme-json-files/

So I am closing this issue. If the change don't fix your issue, please reopen it.

Soean avatar Feb 05 '21 12:02 Soean

Yes, I did state that this occurs when using the new theme.json structure.

To expand further, this issue is when using the new structure: settings > defaults > color > palette

Not using the old structure which was: global > settings > color > palette

Sandstromer avatar Feb 05 '21 13:02 Sandstromer

I am unable to re-open closed issues.

I will test again to see if I am not understanding the new structure or I am missing something really obvious.

Sandstromer avatar Feb 05 '21 13:02 Sandstromer

I was missing also adding the color palette to the root level in addition to the defaults.

For example, this will NOT output the has-black-color style on the front end:

{
    "settings": {
        "defaults": {
            "color": {
                "palette": [
                    { "slug": "black", "name": "Black", "color": "#000" },
                    { "slug": "white", "name": "White", "color": "#fff" }
                ]
            }
        }    
    }
}

but also adding the palette to the root level like this will output has-black-color on the front end:

{
    "settings": {
        "defaults": {
            "color": {
                "palette": [
                    { "slug": "black", "name": "Black", "color": "#000" },
                    { "slug": "white", "name": "White", "color": "#fff" }
                ]
            }
        },
        "root" : {
            "color": {
                "palette": [
                    { "slug": "black", "name": "Black", "color": "#000" },
                    { "slug": "white", "name": "White", "color": "#fff" }
                ]
            }
        }    
    }
}

So it seems that every style has to be written twice, once in the defaults level for the editor, and again in the root level for the front end.

Sandstromer avatar Feb 05 '21 13:02 Sandstromer

Thanks, i reopend the ticket.

I think it is enough if you only use root. Maybe @nosolosw or @aristath can help.

Soean avatar Feb 05 '21 14:02 Soean

If only using root then the custom palette is only available in the Site Editor, with the custom palette missing from the Post/Page Editor (it defaults to core palette instead).

Sandstromer avatar Feb 05 '21 15:02 Sandstromer

:wave: Thanks for reporting, I can repro this bug. I'll work on a fix.

oandregal avatar Feb 05 '21 16:02 oandregal