-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Open
Labels
[Block] ArchivesAffects the Archives BlockAffects the Archives Block[Block] BreadcrumbsAffects the Breadcrumbs BlockAffects the Breadcrumbs Block[Block] CalendarAffects the Calendar BlockAffects the Calendar Block[Block] Latest CommentsAffects the Latest Comments BlockAffects the Latest Comments Block[Block] RSSAffects the RSS Block - used to display entries from an RSS/Atom feedAffects the RSS Block - used to display entries from an RSS/Atom feed[Package] Block library/packages/block-library/packages/block-library[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Description
See: #74228
What problem does this address?
Dynamic blocks using the ServerSideRender component have two extra divs:
- The wrapper div with the blockProps applied
- The div output by the
RawHTMLcomponent
<div class="block-editor-block-list__block wp-block wp-block-test"> <!-- The wrapper div with the blockProps applied -->
<div><!-- The div output by the RawHTML component -->
<p class="wp-block-test">Dynamic block content</p>
</div>
</div>
</div>These extra div elements may require special CSS overrides for the editor.
What is your proposed solution?
- Use the
HTMLRenderercomponent anduseServerSideRender()hook to eliminate these extra divs and make the HTML on the front end and editor match. We can refer to the implementation of the Tag Cloud block. - If the block has any special CSS for the editor, we may be able to remove it.
- Make sure the global styles work correctly in the editor as before.
Here are the blocks to work on:
- PHP-Only block (See this code) PHP-only blocks: use
HtmlRendererto ensure fontend & editor consistency #74261 - Archives (
core/archives) Archives Block: Use new HtmlRenderer component to remove extra div wrapper and remove editor styles #74255 - Breadcrumbs (
core/breadcrumbs) Breadcrumbs Block: Use HtmlRenderer to remove extra div from editor #74273 - Calendar (
core/calendar) Calender Block: Use HtmlRenderer to remove extra div from editor #74271 - Latest Comments (
core/latest-comments) Latest Comments: Remove wrapper div and use HtmlRenderer for dynamic content rendering #74277 - RSS (
core/rss) RSS Block: Use HtmlRenderer to remove extra div from editor and remove editor styles #74272
Note that we don't have to address everything in one PR - address one block per PR and test carefully.
Metadata
Metadata
Assignees
Labels
[Block] ArchivesAffects the Archives BlockAffects the Archives Block[Block] BreadcrumbsAffects the Breadcrumbs BlockAffects the Breadcrumbs Block[Block] CalendarAffects the Calendar BlockAffects the Calendar Block[Block] Latest CommentsAffects the Latest Comments BlockAffects the Latest Comments Block[Block] RSSAffects the RSS Block - used to display entries from an RSS/Atom feedAffects the RSS Block - used to display entries from an RSS/Atom feed[Package] Block library/packages/block-library/packages/block-library[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] EnhancementA suggestion for improvement.A suggestion for improvement.