Skip to content

Group blocks get corrupted after upgrade to 15.1 if they had an HTML anchor set #48128

@ahegyes

Description

@ahegyes

Description

After upgrading to version 15.1 of the Gutenberg plugin, core/group blocks with HTML anchors lose all their inner blocks upon saving the editor.

Step-by-step reproduction instructions

  1. Add a core/group block to a page using Gutenberg 15.0.1 or earlier.
  2. Add a few inner blocks to that group block.
  3. Set an HTML anchor to that group block.
  4. Upgrade to Gutenberg 15.1 or newer.
  5. Open the editor containing said group block and click on Update.
  6. Refresh the editor and/or the page itself. The inner blocks are now gone.

Screenshots, screen recording, code snippet

Here is an example of the post_content value in the database for a test page created with Gutenberg 15.0.1:

<!-- wp:group {"layout":{"type":"constrained"}} -->
<div id="my-test-group-anchor" class="wp-block-group"><!-- wp:heading -->
<h2 class="wp-block-heading">Heading inside group</h2>
<!-- /wp:heading --></div>
<!-- /wp:group -->

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

The page content itself looks like this: https://d.pr/i/hxLPJT

After upgrading to Gutenberg 15.1 (confirmed also with 15.1.1), when opening the page in the editor, there are these two entries in the console log: https://d.pr/i/vRLLLY

If I change nothing on the page but simply click on Update, the page content will look like this: https://d.pr/i/7CSZjO (no more Heading inside group).

If I then reload the Gutenberg editor for that page, there is this error in the console log: https://d.pr/i/3v0uBI and the group itself looks like this: https://d.pr/i/OLUPsU

The post_content value in the database is now:

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

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

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backwards CompatibilityIssues or PRs that impact backwards compatability[Block] GroupAffects the Group Block (and row, stack and grid variants)[Type] BugAn existing feature does not function as intended[Type] RegressionRelated to a regression in the latest release

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions