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

BlockPreview should render styles #30680

Closed
javierarce opened this issue Apr 9, 2021 · 5 comments
Closed

BlockPreview should render styles #30680

javierarce opened this issue Apr 9, 2021 · 5 comments
Labels
[Feature] Custom Editor Styles Functionality for adding custom editor styles [Feature] Navigation Component A navigational waterfall component for hierarchy of items.

Comments

@javierarce
Copy link
Contributor

Description

While reviewing this issue we noticed that the previews in the Full Site Editor (FSE) template sidebar don't truly represent the design in the editor.

The reason seems to be that the BlockPreview component doesn't load styles (in this case, the ones from the editor) or the way this component is used in the template preview. In any case, fixing the previews by loading the editor styles could help users better identify the different templates while they work with the FSE.

Step-by-step reproduction instructions

  1. Set up a test site with the latest version of Gutenberg
  2. Install and activate a theme that supports FSE (like the TT1 blocks theme).
  3. Head to the Site Editor (beta) tab and open any template.
  4. Change the Global Styles and set the background color to red.
  5. Click on the WordPress menu to open the template sidebar.
  6. Hover some templates to make the preview appear.

Expected behaviour

The template previews should show a red background.

Actual behaviour

The template previews show a white background.

Screenshots or screen recording

Screenshot 2021-04-09 at 17 59 35

The code rendered by the component doesn't seem to include any CSS related to the theme:

Screenshot 2021-04-09 at 18 15 11

WordPress information

  • WordPress version: 5.7
  • Gutenberg version: 10.3.2
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? No (see step-by-step instructions)

CC @annezazu @jasmussen

@jasmussen jasmussen added [Feature] Custom Editor Styles Functionality for adding custom editor styles [Feature] Full Site Editing [Feature] Navigation Component A navigational waterfall component for hierarchy of items. labels Apr 9, 2021
@jasmussen
Copy link
Contributor

Thanks for ticketing this!

On the one hand this seems like a logical extension of the stylesheet being loaded into the site editor iframe, and so the editor-styles-wrapper classes of the thumbnail component don't pick up those sandboxed styles.

On the other hand, I could swear this used to be working, not that long ago. @ellatrix do you recall if this broke with the iframe and have been broken since?

@ramonjd
Copy link
Member

ramonjd commented May 11, 2021

I can replicate this for most patterns where the theme adds specific styling. I haven't confirmed, but I suspect that the theme css isn't being loaded in the iframe context?

This is tested with the current master branch (10.6.0-rc.1) using TT1 blocks, and no modifications:

Site editor Block editor
Screen Shot 2021-05-11 at 1 24 31 pm Screen Shot 2021-05-11 at 12 23 10 pm
Screen Shot 2021-05-11 at 1 45 25 pm Screen Shot 2021-05-11 at 1 45 51 pm

On the one hand this seems like a logical extension of the stylesheet being loaded into the site editor iframe, and so the editor-styles-wrapper classes of the thumbnail component don't pick up those sandboxed styles.

There's a related issue over here: #31022

@jasmussen
Copy link
Contributor

I can replicate this for most patterns where the theme adds specific styling. I haven't confirmed, but I suspect that the theme css isn't being loaded in the iframe context?

Well the popover is not part of the iframe. So even if the editor style is loaded inside the iframe, it's not loaded outside the iframe:

Screenshot 2021-05-11 at 09 17 30

So it seems the solution is to either also load the editor style outside the iframe, in the site editor, or wrap each preview inside other iframes that load the editor styles.

@ramonjd
Copy link
Member

ramonjd commented May 11, 2021

Well the popover is not part of the iframe

Ah sorry for the red herring there. Thanks for the extra info.

@ellatrix
Copy link
Member

Should be fixed after #28165.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Custom Editor Styles Functionality for adding custom editor styles [Feature] Navigation Component A navigational waterfall component for hierarchy of items.
Projects
None yet
Development

No branches or pull requests

4 participants