Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSE: Theme's stylesheet is enqueued outside the editor's <iframe> #28774

Closed
adsheyn opened this issue Feb 5, 2021 · 5 comments
Closed

FSE: Theme's stylesheet is enqueued outside the editor's <iframe> #28774

adsheyn opened this issue Feb 5, 2021 · 5 comments
Labels
Needs Testing Needs further testing to be confirmed.

Comments

@adsheyn
Copy link

adsheyn commented Feb 5, 2021

Description

After upgrading Gutenberg plugin from 8.9.3 to 9.0 I've noticed that all the stylesheets that were before enqueued inside the editor's <iframe> window are now outside of it. I've tested this with my custom block-based theme as well as with TT1. Stylesheets are enqueued using the add_editor_style() function and worked before properly.

Step-by-step reproduction instructions

  1. Open the Site Editor window.
  2. Open the Browser's Dev Tools.
  3. Scroll to the bottom and see that all the stylesheets are there.

Expected behavior

Stylesheets provided by the theme should be enqueued inside of the editor's <iframe>.

WordPress information

  • WordPress 5.6.1
  • Gutenberg version: 9.0.0
  • All plugins except Gutenberg are deactivated.
  • Tested with TT1, and custom block-based theme.

Device information

  • Device: iMac
  • Operating system: iOS 10
  • Browser: Chrome 88.0
@adsheyn
Copy link
Author

adsheyn commented Feb 5, 2021

Another problem with styles...
On Post / Page edit screen there is this:

<style>.editor-styles-wrapper a { color: var(--wp--style--color--link, #00e); }</style>

Setting "link" to false inside theme.json doesn't change anything.
How to get rid of this?

@gwwar gwwar added the Needs Testing Needs further testing to be confirmed. label Feb 5, 2021
@ndiego
Copy link
Member

ndiego commented Feb 7, 2021

👏 I have being trying to find the cause of this problem for hours and just stumbled upon this ticket. I have opened at ticket (WordPress/theme-experiments#201) in the Theme Experiments repo thinking it had something to do with the new experimental-theme.json file.

But yes, I can confirm this issue with a similar testing setup to @adsheyn.

@aristath
Copy link
Member

aristath commented Feb 8, 2021

This has already been fixed in #28731 so it will be included in the next minor release 👍

@aristath aristath closed this as completed Feb 8, 2021
@adsheyn
Copy link
Author

adsheyn commented Feb 8, 2021

Thanks for looking into this @aristath and @nosolosw .
I've just checked the latest fixes to this problem #28731 but unfortunately, now this is even more strange.
Please look at the screenshot below:

Screen Shot 2021-02-08 at 15 08 33-min

All the styles are double enqueued. Right at the beginning of the <body/> tag as well as at the end of it.

There is also problem with the included styles itself. Some of them should not be enqueued at all.

1.) The first stylesheet contains this:

Screen Shot 2021-02-08 at 15 36 01

I understand the need to provide some default stylling for the editor, but when a theme author provides their own styles through the add_editor_style() function, these defaults should not be included at all. That is very important because overriding them provides specifity problems. Especcially for plugin authors trying to style particular components.

2.) Default set of font families.

Screen Shot 2021-02-08 at 15 36 10

Similary to the previous styles... As a theme developer I always declare font families to the basic html elements. Currently I have to do this: .editor-styles-wrapper p { . . . } to override that... and what if a theme has different font families for section heading, subheading, page titles or links inside heading tags?

I really think that these kind of styles (editor defaults) should only be included if the theme has no add_theme_support( 'editor-styles' ); in functions.php.

3.) Styles that comes from the theme using the add_editor_style() function.

4.) Styles that comes from the theme using the add_editor_style() function.

5.) Default editor variables that comes from the theme.json.

Screen Shot 2021-02-08 at 16 15 47

Well, this is not actually a big problem, but I believe that css variables should come first. It is rather personal preference.

6.) Classes generated by the theme.json file.

Screen Shot 2021-02-08 at 15 36 27

At the very beginning there is: .editor-styles-wrapper a { color: var(--wp--style--color--link, #00e); }.
How to turn of this default color for links? Setting "link" to false doesn't work.

Also, how to prevent automatic generation of these styles?

@ndiego
Copy link
Member

ndiego commented Feb 8, 2021

@adsheyn see the additional comments in #28731. Looks like this was a hotfix to get the Site Editor working again, but additional iteration is needed get things working 100%. #28837 is working to address the duplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Testing Needs further testing to be confirmed.
Projects
None yet
Development

No branches or pull requests

4 participants