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

Make editor CSS more specific so it doesn't leak out of the editor #46877

Closed
johngodley opened this issue Jan 4, 2023 · 1 comment
Closed
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. [Type] Enhancement A suggestion for improvement.

Comments

@johngodley
Copy link
Contributor

Some editor CSS leaks out of the editor and can affect the surrounding page. When Gutenberg is used inside wp-admin this is not a problem as the CSS has been designed to fit there, but if Gutenberg is used in another context then this leaky CSS means that CSS overrides are needed, and things get messy. This is more apparent if the editor is used on the same page as rendered blocks.

For example, Gutenberg is used on the wordpress.org support forums, which are front-end pages not in wp-admin. These pages contain rendered blocks. For example, the page footer is a navigation block. CSS from the editor .wp-block-navigation-item .wp-block-navigation-item__content adds a cursor style which overrides the page style (and which must then be specifically overridden on the page to restore it).

The CSS comes from the Gutenberg editor.css file. Looking through this it seems to contain a lot of CSS that will affect rendered blocks. If the CSS is only for the editor then ideally it should be made specific to the editor.

i.e. .wp-block-navigation-item .wp-block-navigation-item__content becomes .block-editor__container .wp-block-navigation-item .wp-block-navigation-item__content

What is your proposed solution?

Increase the specificity of editor CSS so it is tied to something in the editor.

@johngodley johngodley added [Type] Enhancement A suggestion for improvement. CSS Styling Related to editor and front end styles, CSS-specific issues. labels Jan 4, 2023
@ellatrix
Copy link
Member

This is fixed by #48286. All editors are now iframed by default. The post editor will be iframed if all blocks are v3 or higher. If you're creating a custom block editor, make sure to use the Iframe component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

2 participants