You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Style hooks - default values cause extra wrappers and block errors in editor for standard blocks. #24387
[Feature] Custom Editor StylesFunctionality for adding custom editor styles[Feature] ParsingRelated to efforts to improving the parsing of a string of data and converting it into a different f[Type] BugAn existing feature does not function as intended
// allow blocks to specify their own attribute definition with default values if needed.
if(!settings.attributes.backgroundColor){
Object.assign(settings.attributes,{
backgroundColor: {
type: 'string',
},
});
However, in practice this seems to not play nice in the editor. With standard blocks (reproduced with Paragraph and Heading), default styles add extra wrappers in the editor and can break the blocks.
To reproduce
Below I will explore this with a standard block, "Paragraph".
Add the following to attributes in Paragraph's block.json file:
To support p-less paragraph blocks we have a "deprecated" version for the paragraph block used to auto-add the p wrapper. I think that's probably what's causing the double paragraphs here. I saw in the past that this deprecated version of paragraph block caused other similar issues (double p), so I wonder if we can rework it and try to apply it only when we detect p-less paragraphs.
I retested this on WordPress 7.1.2 with Gutenberg trunk (late July 2026). I gave Paragraph and Heading default textColor, backgroundColor and fontSize values, set custom values, changed the background again, and round-tripped the content through save/parse. Every round trip produced a single valid <p>/<h2> with the expected classes, with no nested wrapper and no invalidation. Closing as no longer reproducible; if you can still trigger the double wrapper, please reopen with the attribute setup you used.
[Feature] Custom Editor StylesFunctionality for adding custom editor styles[Feature] ParsingRelated to efforts to improving the parsing of a string of data and converting it into a different f[Type] BugAn existing feature does not function as intended
Activity
Addison-Stavlo commentedon Aug 5, 2020
FYI @youknowriad (not to be confused with #24363)
youknowriad commentedon Aug 6, 2020
This only applies to paragraphs right?
To support p-less paragraph blocks we have a "deprecated" version for the paragraph block used to auto-add the p wrapper. I think that's probably what's causing the double paragraphs here. I saw in the past that this deprecated version of paragraph block caused other similar issues (double p), so I wonder if we can rework it and try to apply it only when we detect p-less paragraphs.
Addison-Stavlo commentedon Aug 6, 2020
It seems to be the case with the heading block as well. I haven't tested beyond those two currently.
youknowriad commentedon Aug 10, 2020
In that case, it's a different story independent with the "p -less" deprecation.
annezazu commentedon Sep 2, 2020
Just an FYI that I did the best I could to label this but if others have a better possible label, please update!
youknowriad commentedon Oct 15, 2026
I retested this on WordPress 7.1.2 with Gutenberg trunk (late July 2026). I gave Paragraph and Heading default
textColor,backgroundColorandfontSizevalues, set custom values, changed the background again, and round-tripped the content through save/parse. Every round trip produced a single valid<p>/<h2>with the expected classes, with no nested wrapper and no invalidation. Closing as no longer reproducible; if you can still trigger the double wrapper, please reopen with the attribute setup you used.