Block Style variations that share the same name can overwrite each other #21386
Labels
[Feature] Extensibility
The ability to extend blocks or the editing experience
[Feature] Theme Style Variations
Related to style variations provided by block themes
[Status] Duplicate
Used to indicate that a current issue matches an existing one and can be closed
If you are using multiple blocks that have the block style variation name, their styles will be reproduced on other blocks, leading to unintentional styling conflicts on blocks.
Right now, block style variations are used to provide styling variations that would slightly modify an entire block (like background-color, border colors) of a particular block. Block Style Variations can be applied on blocks within Gutenberg and custom blocks from 3rd-party developers that a user may install.
These block style variations create classes whose names are fixed: 'is-style' followed by the name of that the developer gives to the variation class. Some of these variation names can have generic names.
e.g. if you have a style variation named secondary, the class generated named is
.is-style-secondary
Because block style variations rely on a single class name and users will have multiple blocks from multiple sources on their websites, it will be inevitable that users that have style variations with the same name.
These styling conflicts/leaks will occur within the editor even if only one of the blocks is present on a page.
These styling conflicts/leaks will occur across different themes if the plugins' blocks have style variations with the same name.
To reproduce
Steps to reproduce the behavior:
Install Rich Tabor's coblocks (Not to pick on you Rich, it's just an example of a popular block plugin that also has somewhat common style variation names). It has an 'alert' block with a style variation named 'success'
Install my example plugin. https://gitlab.com/cpl/cpl-example
The cpl-example block has a block style variation of the quote block named 'success' (https://gitlab.com/cpl/cpl-example/-/blob/master/src/index.js#L17)
activate both plugins
create a page that contains an alert block from coblocks
This first image is when the coblocks plugin is installed., the block displays with the style that the block author has intended. This is before my plugin is activated.
After activating my plugin, you'll see a result similar to the image below; where the font-size and the border of my block variation style leaks into the coblock because they both share the same class,
.is-style-success
Examples of where this occurs or was mentioned:
CakeWP/block-options#249 (comment)
The text was updated successfully, but these errors were encountered: