Better scope the "Vanilla Block Styles" CSS selectors #17702
Labels
[Package] Block library
/packages/block-library
[Type] Bug
An existing feature does not function as intended
Describe the bug
We currently faced a CSS conflict issue with our plugin meta box and after some digging it appears Gutenberg uses some very general CSS selectors in the
block-library
stylesheet. See:gutenberg/packages/block-library/src/style.scss
Lines 174 to 196 in a1eda99
While I do understand the need to target some elements across all blocks (which by the way goes a bit against the principle of isolated, reusable, components), it appears some of thes CSS selectors aren't scoped at all and they target all the related elements. Even the ones in the UI added by plugins, whether it's a meta box or a sidebar or anything else.
They even target any related element in the WordPress admin UI, which may potentially produce breakages. I'd tend to think this shouldn't happen and these selectors should be better scoped.
Specifically:
img
type selector targets any image in the edit post page: I'd say this is the most important casefigcaption
andiframe
selectors:figcaption
andiframe
are likely less used by plugins but there's a potential of breakage anyways.To my understanding, the main goal of these "Vanilla Block Styles" is to provide some baseline styles for all the blocks. If so, seems to me they should at least be better scoped with an additional selector that targets the blocks area and excludes all the rest of the page.
The text was updated successfully, but these errors were encountered: