Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

WooCommerce block templates load unreliably inside the Site Editor. #8378

Closed
tjcafferkey opened this issue Feb 3, 2023 · 6 comments
Closed
Labels
focus: template Related to API powering block template functionality in the Site Editor priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. status: blocked The issue is blocked from progressing, waiting for another piece of work to be done. type: bug The issue/PR concerns a confirmed bug.

Comments

@tjcafferkey
Copy link
Contributor

tjcafferkey commented Feb 3, 2023

Describe the bug

The Site Editor appears to be unreliable at loading the WooCommerce block templates, and on occasions just presents the user with a blank template despite that not being the case.

This has become apparent when testing #8308 (comment) but is an existing issue.

In my opinion, this really impacts the user experience of our block template feature and the effort we are currently putting into it. Especially since there is a really high chance the user will be impacted upon their first impression when testing/using this feature.

To reproduce

Steps to reproduce the behavior:

  1. From the WP dashboard, browser to Appearance > Site Editor
  2. Click "Manage templates" to view the template list
  3. Click into various WooCommerce block templates making sure you navigate between them using the browsers "Back" button.
  4. Observe how at random, some of them do not load and appear as a blank template. (Fixed by refreshing the page on the blank template)

Expected behavior

The correct block template will load its contents.

Screenshots

wc-block-templates-not-loading.mp4

Environment

WordPress:

  • WordPress version: 6.1.1
  • WooCommerce version: 7.3.0
  • WooCommerce Blocks version: 9.5.0
@tjcafferkey tjcafferkey added type: bug The issue/PR concerns a confirmed bug. focus: template Related to API powering block template functionality in the Site Editor priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. labels Feb 3, 2023
@dinhtungdu dinhtungdu self-assigned this Feb 13, 2023
@dinhtungdu
Copy link
Member

Update: Look like we have some issue with template fallback mechanism, I changed the BlockTemplateUtils::ELIGIBLE_FOR_ARCHIVE_PRODUCT_FALLBACK array to empty and can't reproduce this issue anymore.

@dinhtungdu
Copy link
Member

Update: template fallback isn't the issue. Gutenberg Site Editor has an issue when switching between templates that have identical content. If we disable template fallback but use the same content for all template files, the issue can be reproduced again.

Steps to reproduce

  1. Change the value of BlockTemplateUtils::ELIGIBLE_FOR_ARCHIVE_PRODUCT_FALLBACK to an empty array.
  2. See the issue is no longer reproducible.
  3. Update the content of the following files to use the content of woocommerce-blocks/templates/templates/archive-product.html:
  • woocommerce-blocks/templates/templates/taxonomy-product_tag.html
  • woocommerce-blocks/templates/templates/taxonomy-product_cat.html
  • woocommerce-blocks/templates/templates/taxonomy-product_attribute.html
  1. See the issue is reproducible again.

I'm unassigning myself from this issue so others can work on that because I'm AFK tomorrow. I will continue working on this on Wednesday if needed.

@dinhtungdu dinhtungdu removed their assignment Feb 13, 2023
@albarin
Copy link
Contributor

albarin commented Feb 14, 2023

I've been trying to understand what's happening, I haven't managed to do it, but I'll leave here some more info I've discovered today in case it's useful for someone:

  • The issue is related to this line
    $template_file = $this->get_template_path_from_woocommerce( 'archive-product' );
    where we replace the template file for the archive-product fallback (after commenting that line the issue stops happening).
  • With Gutenberg enabled the issue also stops happening.

@dinhtungdu
Copy link
Member

This is fixed by a side effect of WordPress/gutenberg#47777:

  • With 47777, whenever we browse the list of templates, the preview shows the home template.
  • When another template is selected, the preview is updated accordingly, which fixes this issue by preventing switching between identical templates.

I opened WordPress/gutenberg#48095 to track the issue upstream. Marking this issue as blocked for now.

@dinhtungdu dinhtungdu added the status: blocked The issue is blocked from progressing, waiting for another piece of work to be done. label Feb 15, 2023
@dinhtungdu dinhtungdu removed their assignment Feb 15, 2023
@nefeline
Copy link
Contributor

The Site Editor appears to be unreliable at loading the WooCommerce block templates, and on occasions just presents the user with a blank template despite that not being the case.

I did some tests today on https://liquid-coral.jurassic.ninja/ , with the latest versions of WooCommerce (7.7.0), WooCommerce Blocks (10.2.0), TT3 theme, and WordPress version 6.2.1 and wasn't able to reproduce this issue:

Screen.Recording.2023-05-19.at.17.36.27.mov

I also ran the exact same test while having the latest version of the Gutenberg plugin enabled (15.8.0) and things are working as expected.

@dinhtungdu @albarin @tjcafferkey do you still have any remaining concerns? From my perspective, we are good to close out this issue.

@tjcafferkey
Copy link
Contributor Author

tjcafferkey commented May 19, 2023 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: template Related to API powering block template functionality in the Site Editor priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. status: blocked The issue is blocked from progressing, waiting for another piece of work to be done. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

No branches or pull requests

4 participants