-
Notifications
You must be signed in to change notification settings - Fork 219
WooCommerce Classic Template block: Fix error on clearing customizations on Woo Templates #9759
WooCommerce Classic Template block: Fix error on clearing customizations on Woo Templates #9759
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: +290 B (0%) Total Size: 1.1 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is testing well, but I wasn't able to reproduce the issue in trunk
. I tried with the steps from #9637 and the ones from this PR. I might be missing an important step somewhere. 😕
When the template renders, modify it by adding or removing blocks. Once you finish customizing it, on the top right side, click on Save;
Does it matter if I have the blockified template or the template is using the WooCommerce Single Product Block? Also, does it matter if the other WC templates are blockified or using the legacy block?
When I first tried reproducing the issue, I wasn't able to reproduce it as well. I did a fresh install using the same versions for WordPress, WooCommerce and WooCommerce blocks that are in the issue #9637 and just then I manage to reproduce it
In this particular case, it is important that the template have the WooCommerce Single Product Block (the block name in code is Providing a little bit of context, this specific block is only registered for some templates like the Single Product template. While investigating the problem, I confirmed that the block is being correctly registered (when the page is fully loaded, the block has a registered state), I think the problem is about timing. If I click on Clear all customizations button, wait for the confirmation message and visit the Single Product page, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @thealexandrelara! I'm not sure what I was doing wrong, I think the issue was that I had the Shop page as the home, so when navigating from one template to the other the Classic Template block was being registered automatically. After changing that I could reproduce the issue consistently. Sorry for the confusion!
I have to say the issue is a bit confusing, but I couldn't find a simpler way to solve it. Your solution works well and code looks good too, so approving. I just left one minor comment, I think it would be nice to add a link to the GH issue or PR for future reference, what do you think? Besides that, LGTM.
…ons on Woo Templates (#9759) * Fix Classic Template block error on clearing customizations on template * Add link to issue in JS Doc
* Empty commit for release pull request * Update Hero Product 3-split pattern image * Update Banner Pattern To Replace Unsplash Image (#9760) * Update Banner to replace Unsplash image. Replaces the Unsplash image with a CCO licensed image from Pxhere. Also updates the CTA button to link to the Shop page, by default. * Remove extra padding from top of test column. Vertical alignment was off on the text column due to 60px of top padding. This aligns everythign, as expected. * Update Chessboard pattern images (#9761) * Updathe the Hero Product Split (#9762) * Remove unused pattern image (#9763) * Update Images for the Product Details Patterns (#9764) * Update image for the Product Hero pattern. Replace the Unsplash image with a CCO licensed image from Pxhere. * Update images for Prod List Gallery Desc pattern Replace the Unsplash image with a CCO licensed image from Pxhere for the Product Listing with Gallery and Description pattern. * Remove unneeded Unsplash images. * Update copy for Prod Listing Gallery Desc pattern. * Optimize new image exports. * Update image for the Product Listing pattern. Replace the Unsplash image with a CCO licensed image from Pxhere. * Update images for Product Details pattern. Replace the Unsplash images with CCO licensed images from Pxhere. * Remove unneeded Unsplash image. * Use Relative URLs for Images in the Product Listing Pattern This commit replaces hardcoded URLs with dynamic ones for image placeholders in the `product-listing-with-gallery-and-description.php` pattern file. - The `plugins_url()` function is now used to generate URLs, which correctly points to the images folder within the WooCommerce Blocks plugin directory. This approach provides better flexibility and portability since it doesn't rely on a specific domain or path. The `esc_url()` function is used to ensure the URL is safe to use in the HTML context. - The change is made for a total of four images in the pattern. --------- Co-authored-by: Manish Menaria <[email protected]> * Update/patterns featured category product collection (#9765) * Update image for featured category focus pattern * Update image for featured category cover image pattern * Update images for featured category triple pattern * Change to wide width * Update links to buttons * Fix typo in hex color value. There was an extra `f` in the hex color value, causing the text to unexpectedly render black. --------- Co-authored-by: Daniel W. Robert <[email protected]> * Update/collection pattern images (#9766) * Update featured collections images * Add shop link to shop by price pattern * Update hero product pattern title (#9769) * Remove unused pattern image (#9770) * Add 10.4.2 changelog in readme.txt * Update version number to 10.4.2 * Add testing instructions for 10.4.2 * Add 9769 PR testing steps * WooCommerce Classic Template block: Fix error on clearing customizations on Woo Templates (#9759) * Fix Classic Template block error on clearing customizations on template * Add link to issue in JS Doc * Change the way of debug check of tests-mysql container (#9794) * Add alt text to images used in patterns describing their purpose (#9788) * Add alt text to images used in patterns describing their purpose * Replace 1/3 notation with 1 out of 3, so it's better handled byt screen readers * Update testing instructions to include 9759 PR * Update zip to include 9759 PR * Remove 9759 PR from testing instructions --------- Co-authored-by: github-actions <[email protected]> Co-authored-by: Alba Rincón <[email protected]> Co-authored-by: Daniel W. Robert <[email protected]> Co-authored-by: Alba Rincón <[email protected]> Co-authored-by: Manish Menaria <[email protected]> Co-authored-by: Roy Ho <[email protected]> Co-authored-by: Daniel W. Robert <[email protected]> Co-authored-by: Tarun Vijwani <[email protected]> Co-authored-by: Alexandre Lara <[email protected]> Co-authored-by: Karol Manijak <[email protected]>
* Empty commit for release pull request * Update Hero Product 3-split pattern image * Update Banner Pattern To Replace Unsplash Image (#9760) * Update Banner to replace Unsplash image. Replaces the Unsplash image with a CCO licensed image from Pxhere. Also updates the CTA button to link to the Shop page, by default. * Remove extra padding from top of test column. Vertical alignment was off on the text column due to 60px of top padding. This aligns everythign, as expected. * Update Chessboard pattern images (#9761) * Updathe the Hero Product Split (#9762) * Remove unused pattern image (#9763) * Update Images for the Product Details Patterns (#9764) * Update image for the Product Hero pattern. Replace the Unsplash image with a CCO licensed image from Pxhere. * Update images for Prod List Gallery Desc pattern Replace the Unsplash image with a CCO licensed image from Pxhere for the Product Listing with Gallery and Description pattern. * Remove unneeded Unsplash images. * Update copy for Prod Listing Gallery Desc pattern. * Optimize new image exports. * Update image for the Product Listing pattern. Replace the Unsplash image with a CCO licensed image from Pxhere. * Update images for Product Details pattern. Replace the Unsplash images with CCO licensed images from Pxhere. * Remove unneeded Unsplash image. * Use Relative URLs for Images in the Product Listing Pattern This commit replaces hardcoded URLs with dynamic ones for image placeholders in the `product-listing-with-gallery-and-description.php` pattern file. - The `plugins_url()` function is now used to generate URLs, which correctly points to the images folder within the WooCommerce Blocks plugin directory. This approach provides better flexibility and portability since it doesn't rely on a specific domain or path. The `esc_url()` function is used to ensure the URL is safe to use in the HTML context. - The change is made for a total of four images in the pattern. --------- Co-authored-by: Manish Menaria <[email protected]> * Update/patterns featured category product collection (#9765) * Update image for featured category focus pattern * Update image for featured category cover image pattern * Update images for featured category triple pattern * Change to wide width * Update links to buttons * Fix typo in hex color value. There was an extra `f` in the hex color value, causing the text to unexpectedly render black. --------- Co-authored-by: Daniel W. Robert <[email protected]> * Update/collection pattern images (#9766) * Update featured collections images * Add shop link to shop by price pattern * Update hero product pattern title (#9769) * Remove unused pattern image (#9770) * Add 10.4.2 changelog in readme.txt * Update version number to 10.4.2 * Add testing instructions for 10.4.2 * Add 9769 PR testing steps * WooCommerce Classic Template block: Fix error on clearing customizations on Woo Templates (#9759) * Fix Classic Template block error on clearing customizations on template * Add link to issue in JS Doc * Change the way of debug check of tests-mysql container (#9794) * Add alt text to images used in patterns describing their purpose (#9788) * Add alt text to images used in patterns describing their purpose * Replace 1/3 notation with 1 out of 3, so it's better handled byt screen readers * Update testing instructions to include 9759 PR * Update zip to include 9759 PR * Remove 9759 PR from testing instructions * Mini Cart Block: show the total price, including tax, according to the option (#9878) * Mini Cart Block: show the total price, including tax, according to the option * Fix tests in PR 9878 (#9880) * add unit test --------- Co-authored-by: Karol Manijak <[email protected]> * Mini-Cart: don't include shipping price (#9914) * Products Block: fix grid view with Gutenberg 16 (#9916) * Revert "fix products block layout on gutenberg 16 (#9886)" This reverts commit f1e5dd7. * add post_template_has_support_for_grid_view setting * add testing instructions * bump version * update zip link * Empty commit for release pull request * update link --------- Co-authored-by: github-actions <[email protected]> Co-authored-by: Alba Rincón <[email protected]> Co-authored-by: Daniel W. Robert <[email protected]> Co-authored-by: Alba Rincón <[email protected]> Co-authored-by: Manish Menaria <[email protected]> Co-authored-by: Roy Ho <[email protected]> Co-authored-by: Daniel W. Robert <[email protected]> Co-authored-by: Tarun Vijwani <[email protected]> Co-authored-by: Alexandre Lara <[email protected]> Co-authored-by: Karol Manijak <[email protected]> Co-authored-by: Luigi Teschio <[email protected]> Co-authored-by: Albert Juhé Lluveras <[email protected]>
Description
When the user clears the customizations made on the Single Product template and visits the template page without refreshing the page, an error was occurring that prevented the WooCommerce Classic Template block from being rendered on the Editor.
This PR fixes that error by replacing the 'core/missing' block with the original block (WooCommerce Classic Template) when the template has support to the classic block and the block is already registered.
Walkthrough
🤖 Generated by Copilot at b78ab3d
parse
function to parse block content into block object (link)dispatch
anddebounce
functions to dispatch actions and limit function calls (link)tryToRecoverClassicTemplateBlockWhenItFailsToRender
function to replace 'core/missing' block with original Classic Template block if it fails to render (link)tryToRecoverClassicTemplateBlockWhenItFailsToRender
if block registered and template supports Classic Template block (link, link)subscribe
function with namespace argument of 'core/blocks-editor' to limit subscription scope to block editor store (link)Fixes #9637
Accessibility
prefers-reduced-motion
Other Checks
Screenshots
Testing
Automated Tests
User Facing Testing
WooCommerce Visibility
Performance Impact
Before the changes, the code was subscribing to all events from the
@wordpress/data
, but now the subscription is restricted to the changes on the 'core/block-editor' storage so possible the performance will be better after merging these changes.Changelog