Skip to content

Favorites and My Patterns grid patterns: two block comments close the wrong block #791

Open

Description

@ekamran

Two pattern files in the 2024 theme have a block comment that does not match the block it is meant to close.

  1. patterns/_grid-mine.php, line 63: the Edit wp:button block is closed with <!-- /wp:paragraph -->. I mentioned this one in Show a status-aware empty state on My Patterns #758.
  2. patterns/_grid-favorites.php, line 77: the message group inside wp:query-no-results ends with <!-- wp:group /-->. That is a new, empty, self-closing group block, not a closer, so the message group stays open.

I checked both with parse_blocks() and do_blocks() on WordPress 7.1.3.

The first one has no effect today. The block tree and the rendered HTML are the same as with <!-- /wp:button -->.

The second one shifts the blocks that follow. The spacer and the suggestions group become inner blocks of the message group, <!-- /wp:query-no-results --> closes the message group, and <!-- /wp:query --> closes wp:query-no-results. So the closing </div> of the outer query block (line 107) ends up inside wp:query-no-results. When the user has favorites, that block renders nothing, and the rendered pattern has one <div> that is never closed.

An HTML5 parser repairs this. With PHP 8.5's Dom\HTMLDocument, the DOM of the full page-favorites.html template was the same with and without the fix, ignoring whitespace. So I do not expect a visible change. The served HTML is still unbalanced, and the block tree is not what the file intends.

Expected: each block comment closes the block it opened.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions