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

Editing a page that has a Spacer block with an HTML Anchor produces message “This block contains unexpected or invalid content.” #49382

Closed
jpjfox opened this issue Mar 27, 2023 · 4 comments · Fixed by #51288
Assignees
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Blocks Overall functionality of blocks [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Comments

@jpjfox
Copy link

jpjfox commented Mar 27, 2023

Description

Our website has pages that contain Spacer blocks with HTML Anchors defined. The site has been working for months with this design. Last edits were done in October 2022. Now when I try to edit these pages every one of these Spacer blocks shows the error message “This block contains unexpected or invalid content."

If I choose "Attempt Block Recovery" the Spacer block is restored, but without the anchor. I can then manually add the anchor back, save the page, and all is good... until some future date when a subsequent page edit shows this error again. (What I mean by 'future date' is that I encountered this problem in January 2022, rebuilt the Spacer blocks with Anchors, and everything looked good. The next round of edits in October 2022 worked fine. Then in March 2023 the Spacer Blocks with Anchors choke again when I edit these pages.)

There is no apparent difference in the HTML code generated to specify the anchor between January 2022 and now, but the editor chokes on processing the existing code, then allows adding the Anchor to the Spacer and generates the same code. My expectation is that the existing Spacer does not produce any “This block contains unexpected or invalid content" errors.

Step-by-step reproduction instructions

Steps to reproduce:

  1. Edit an existing page that contains a Spacer block with an HTML Anchor. If the page was last updated over 4–5 months ago the Spacer blocks with Anchors will trip on this error, but if the page was recently edited and saved this error won't occur.
  2. Error shown when existing page is edited:
    Spacer-Anchor (1)
  3. HTML code after "Attempt Block Recovery" chosen:
    Spacer-Anchor (2)
  4. HTML code after recovered Spacer edited to add the same HTML Anchor that was dropped by recovery:
    Spacer-Anchor (3)

Screenshots, screen recording, code snippet

Excerpt from console log showing Block validation messages:
Spacer-Anchor (4)

Environment info

WordPress Version: 6.1.1
WordPress.com Editing Toolkit 3.60227
Gutenberg 15.4.0
Firefox 111.0
Desktop with Windows 10

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

Yes

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

No

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Feature] Blocks Overall functionality of blocks Backwards Compatibility Issues or PRs that impact backwards compatability [Type] Regression Related to a regression in the latest release labels Mar 28, 2023
@t-hamano
Copy link
Contributor

@jpjfox

Thank you for the report.

This problem should occur in all blocks that want to support the anchor. The same problem was reported in #48232 and a fix is being attempted in #48232.

@t-hamano t-hamano added the [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed label Mar 28, 2023
@t-hamano t-hamano self-assigned this Mar 28, 2023
@jpjfox
Copy link
Author

jpjfox commented Mar 29, 2023

Looks like this problem is resolved after WordPress.com Editing Toolkit 3.60608 installed today.

Thanks to all who helped fix this issue.

@jpjfox
Copy link
Author

jpjfox commented Mar 30, 2023

I spoke too soon. Pages I've recently updated show no errors, but when editing older pages I still see “This block contains unexpected or invalid content” on Spacer blocks with Anchors.
After WordPress.com Editing Toolkit 3.60608 plugin installed and WordPress core updated to 6.2.

@t-hamano
Copy link
Contributor

Hi @jpjfox,

This issue is due to the dynamic block anchor support added on the Gutenberg plugin. We have removed this feature from the Gutenberg plugin so this issue will not occur.

Instead, I have submitted #51402 to consider re-adding anchor support to dynamic blocks,

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 [Feature] Blocks Overall functionality of blocks [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
None yet
2 participants