Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ahegyes opened this issue Feb 16, 2023 · 2 comments
Closed
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Block] Group Affects the Group Block (and row, stack and grid variants) [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Comments

@ahegyes
Copy link

ahegyes commented Feb 16, 2023

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

@kathrynwp kathrynwp added [Type] Bug An existing feature does not function as intended [Block] Group Affects the Group Block (and row, stack and grid variants) [Type] Regression Related to a regression in the latest release Needs Testing Needs further testing to be confirmed. labels Feb 16, 2023
@t-hamano
Copy link
Contributor

@ahegyes
Thanks for the reporting. I found a similar issue and submitted it as #48232.

@t-hamano t-hamano added Backwards Compatibility Issues or PRs that impact backwards compatability and removed Needs Testing Needs further testing to be confirmed. labels Feb 19, 2023
@t-hamano
Copy link
Contributor

t-hamano commented Mar 1, 2023

@ahegyes
The reported problem is related to the backward compatibility of anchor support. We tried to resolve this issue in #48438, but in order to find a more ideal solution, we decided to revert the dynamic block anchor support feature in #48592. Let's close this issue so that we can focus on tracking this issue in #48232.

Thank you for finding this issue!

@t-hamano t-hamano closed this as completed Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Block] Group Affects the Group Block (and row, stack and grid variants) [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

No branches or pull requests

3 participants