WordPress / create-block-theme

A WordPress plugin to create block themes

Home Page:https://wordpress.org/plugins/create-block-theme/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Saving template with nested cover blocks to the theme wipes the contents of the inner cover block

andersnoren opened this issue · comments

If you create a template part, add a cover block to that template part and add blocks inside the cover block, saving the changes to the theme with Create Block Theme will wipe the contents of the cover block.

After running into this issue on a separate project, it seems to happen when you have nested cover blocks in a template. See this comment for updated steps to reproduce.

Thank you for the detailed steps. I followed them as closely as I could however I was unable to reproduce this issue.

I found that the cover.php pattern was created as expected, the Cover block was included and the content inside was as well (additionally the content I expected to be localized via PHP was localized as expected).

Additionally I attempted this with a blank theme and the result was the same.

Weird! I can't recreate this either now. It must have been a temporary issue on my local setup, although I did run into it twice on two different WP installs (both local). I'm closing the issue for now. Thanks for trying to recreate, and sorry for the wasted time.

I ran into this again on a separate project, so I decided to create a little block theme to make it easier to replicate the issue. I've made the theme as small as possible.

cover-test.zip theme

Steps to reproduce

  1. Activate the theme.
  2. Open the Site Editor, and add some text to the paragraph in the inner cover block (in home.html).
  3. Save the changes, click the CBT tab, then "Save Changes to Theme", and then the "Save Changes" button.
  4. As soon as the page has reloaded, you'll see that the inner cover block (with the red background) has disappeared. If you check the theme folder, the home.html template has replaced <!-- wp:pattern {"slug":"cover-test/home"} /--> with HTML block markup, but without the inner cover block.

I used a pattern for the home content so I could use <?php echo esc_url( get_stylesheet_directory_uri() ); ?> for the image URLs, but the same thing happens if you move the pattern contents to home.html and write out the image paths before following the steps to reproduce.

Setup

WordPress 6.5.2
Create Block Theme 2.1.0
Without Gutenberg active

Thank you so much for the detailed steps @andersnoren

I have reproduced, added unit tests and fixed the issue in #587. This will be fixed in the next release.