-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Using multiple stylesheets per block does not work in Site Editor #46702
Comments
I believe the issue here is that - in the Site Editor - the block is rendered inside of an iframe that does not have actually have the CSS file included. The CSS file is only in the top-level frame, which is why the paragraph in the sidebar is red. I think there are lots of open issues related to this, such as: #41821 |
I am able to confirm this, but I could have sworn this used to work. @justintadlock I know you recently wrote an article on per-block stylesheets. Did you run into this? |
Actually, I didn't test loading multiple stylesheets per block. But, loading a single stylesheet per block is working for me: I'm also registering on |
I don't remember where I saw this, but I believe that the issue in the original post is that the stylesheet doesn't contain any rules about "wp-block". I just made a sample plugin with the following CSS only, registered with admin_enqueue_scripts, and it does NOT get included in the Site Editor: however, only changing the CSS file to add a line containing .wp-block makes the CSS be included in the Site Editor: .j-sample-block-output-backend-red p { color: red; } .wp-block { background-color: yellow; } |
This might be the best thread for discussion around the need for "wp-block" to be included in the CSS file: |
Yes, I can confirm @pagelab's results. Adding a per-block stylesheet for paragraphs without I added the following to a paragraph stylesheet:
This then causes the file to be loaded in the iframe, but the styles also bleed into the Site Editor. |
This should be fixed by #49655 (in WP 6.3), because |
I am still experiencing this issue on version 6.4.2 |
Description
According to this manual, styles are only loaded in the Page Editor and Frontend, but not in the Site Editor.
Step-by-step reproduction instructions
1. Add the following code snippet to the functions.php file:
2. Add styles in the paragraph.css file:
p { background: red}
3. Check that the styles are loaded in the Site Editor.
Screenshots, screen recording, code snippet
Front-end:
Page Editor:
Site Editor:
Environment info
Fresh install WP (6.1.1) with TT3 theme.
Gutenberg: 14.7.3 & 14.9.20221216 & without.
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
The text was updated successfully, but these errors were encountered: