• Resolved edhomex

    (@edhomex)


    I am part of a team working on a large scale multisite WordPress project that makes heavy use of Gutenberg blocks.

    As is well known amongst Gutenberg developers, you’ll often see “This Block Contains Unexpected or Invalid Content” in the editor after making changes to the block’s attributes and/or HTML markup.

    This error is usually resolved by clicking “Attempt Block Recovery”, but our design team has
    deemed that presenting this error to the (non-developer) user every time there is a block update is not acceptable.

    We use common blocks across the site which may occur many times throughout the site, meaning the “Attempt Block Recovery” must be clicked manually on every block in the backend site-wide. This ends up creating a frustrating and tedious user experience for content editors.

    It seems to me that the only safeguard we have for this is making use of the deprecation system, but the deprecation system over multiple updates gets extremely messy, bloated and confusing to work with (especially with large complex blocks like the custom ones we have developed).

    We have found that this poses a long term problem for both users and developers.

    This leads me to a couple questions:
    1) Is there any hope of eliminating or reducing “This Block Contains Unexpected or Invalid Content” errors when blocks receive updates?
    2) Is there a better alternative than using the deprecation system?
    3) Even though its probably a bad idea, is there a setting to automatically attempt block recovery after updates are pushed?

    If it helps, here is some project info:
    – We are using the latest versions of WordPress & Gutenberg
    – The project is bootstrapped with create-guten-block ( https://github.com/ahmadawais/create-guten-block ).
    – The project is a multi-site instance

    Thanks for reading and let me know if there is any more information or context I can provide on this problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • No answer provided…just more info.

    This happens to me, as well. The blocks effected are all dynamic, custom blocks. The error is on “save.” The console shows that “save” returns nothing (not null, just nothing) and that the post content is this (with cbd-eecs-block/course-list-block and w-block-cbd-eecs-block-course-list-block varying depending on the name of the block):

    <!– wp:cbd-eecs-block/course-list-block –>
    <div class=”components-placeholder wp-block-cbd-eecs-block-course-list-block”><div class=”components-placeholder__label”></div><div class=”components-placeholder__fieldset”><span class=”components-spinner”></span></div></div>
    <!– /wp:cbd-eecs-block/course-list-block –>

    When I remove and re-add the block, the post content changes to this:

    <!– wp:cbd-eecs-block/course-list-block /–>

    And all is fine.

    The thing is, I can’t figure out why it changes in the first place. I can write a script that replaces all of the “bad” content with the acceptable content and have my client run the script every time blocks break, but it seems like there must be a better solution.

    Plugin Author Ella

    (@ellatrix)

    Hi @edhomex!

    I agree that block validation and recovery could be much improved.

    This might be an interesting read for you: https://github.com/WordPress/gutenberg/issues/7604. I recommend sharing your experience there as well! Since this is more of an enhancement request, it’s better to communicate it on Github.

    Plugin Author Ella

    (@ellatrix)

    Since there are existing open issues on Github, I’m marking this topic as resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘This Block Contains Unexpected or Invalid Content’ is closed to new replies.