Skip to content

Several blocks with the anchor are broken in the update #48232

@t-hamano

Description

@t-hamano

In WordPress 6.1.1, if the content contains blocks with the anchor, updating to WordPress 6.2 Beta2 will break some blocks.

I created the following content in WordPress 6.1.1:

<!-- wp:paragraph -->
<p>Paragraph without anchor</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p id="anchor">Paragraph with anchor</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Heading without anchor</h2>
<!-- /wp:heading -->

<!-- wp:heading -->
<h2 id="anchor">Heading with anchor</h2>
<!-- /wp:heading -->

<!-- wp:group {"layout":{"type":"constrained"}} -->
<div id="anchor" class="wp-block-group"></div>
<!-- /wp:group -->

6 1

If you update this environment to WordPress 6.2, the markup will change as follows:

<!-- wp:paragraph -->
<p>Paragraph without anchor</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><p id="anchor">Paragraph with anchor</p></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Heading without anchor</h2>
<!-- /wp:heading -->

<!-- wp:heading {"anchor":"anchor"} -->
<h2 class="wp-block-heading" id="anchor">Heading with anchor</h2>
<!-- /wp:heading -->

<!-- wp:group {"layout":{"type":"constrained"}} /-->

A comparison of the markups confirms the following three points:

  • The paragraph block with the anchor are nested in the p element
  • A comment about anchor attributes has been added to the heading block
  • The anchor in the group block are missing

Now save the post, updating only the title, and reload the browser. Then the block will be broken as follows:

6 2

The browser console displays the following error:

react_devtools_backend.js:4012 Block validation: Block validation failed for `core/paragraph` ({name: 'core/paragraph', icon: {…}, keywords: Array(1), attributes: {…}, providesContext: {…}, …}).

Content generated by `save` function:

<p></p>

Content retrieved from post body:

<p><p id="anchor">Paragraph with anchor</p></p>

---------------

react_devtools_backend.js:4012 Block validation: Block validation failed for `core/group` ({name: 'core/group', icon: {…}, keywords: Array(4), attributes: {…}, providesContext: {…}, …}).

Content generated by `save` function:

<div class="wp-block-group"></div>

Content retrieved from post body:

Metadata

Metadata

Assignees

Labels

Backwards CompatibilityIssues or PRs that impact backwards compatability[Priority] HighUsed to indicate top priority items that need quick attention[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions