Skip to content

Product Details: prevent the default template to be auto applied for existing blocks #59691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

dinhtungdu
Copy link
Member

@dinhtungdu dinhtungdu commented Jul 16, 2025

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR prevents the existing Product Details blocks from upgrading to the new Accordion layout automatically and ensures the new layout will only be applied to newly inserted blocks.

Closes #59663
Closes wooplug-5015

(For Bug Fixes) Bug introduced in PR #59005

Screenshots or screen recordings:

Screen.Recording.2025-07-16.at.09.41.16.mov

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Using Code Editor, add this to the Single Product template: <!-- wp:woocommerce/product-details {"className":"is-style-minimal"} /-->. This simulates the existing Product Details block.
  2. Update and reload the editor.
  3. Switch to the visual editor.
  4. See the Product Details block unchanged, still a single block without any nested blocks.
  5. Add a new Product Details block to the template.
  6. See the Accordion layout is used for the newly inserted block.
  7. Reload the editor again.
  8. Delete the Accordion Group block inside Product Details.
  9. See the legacy editor preview of the previous version of the block rendered.

Note: If the Accordion Group block is deleted right after being inserted into the editor, the legacy preview won't show. The preview is added to maintain backward compatibility for existing instances of the block.

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jul 16, 2025
@woocommercebot woocommercebot requested review from a team and Aljullu and removed request for a team July 16, 2025 02:49
Copy link
Contributor

github-actions bot commented Jul 16, 2025

Testing Guidelines

Hi @Aljullu ,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

Copy link
Contributor

coderabbitai bot commented Jul 16, 2025

📝 Walkthrough

"""

Walkthrough

A patch-level fix was introduced to the WooCommerce product details block to address template application behavior. The Edit component now conditionally applies the default template and renders a legacy preview when appropriate. A new SCSS file styles the editor preview, and a LegacyProductDetailsPreview React component provides a tabbed interface for block previews. Deprecated block migration logic was removed.

Changes

File(s) Change Summary
plugins/woocommerce/changelog/wooplug-5015-woo-1002-products-details-block-regression-compatibility Added changelog entry documenting a patch fix for template application in product details block.
plugins/woocommerce/client/blocks/assets/js/blocks/product-details/edit.tsx Updated Edit to conditionally apply templates and render a legacy preview, added state checks, and imported new components/styles.
plugins/woocommerce/client/blocks/assets/js/blocks/product-details/editor.scss Added new SCSS file for editor preview styling of the product details block.
plugins/woocommerce/client/blocks/assets/js/blocks/product-details/legacy-preview.tsx Introduced new LegacyProductDetailsPreview React component with accessible tabbed interface for block previews.
plugins/woocommerce/client/blocks/assets/js/blocks/product-details/index.tsx Removed deprecated block migrate function; no migration logic now applied for the deprecated version.

Sequence Diagram(s)

sequenceDiagram
    participant Editor
    participant EditComponent
    participant LegacyProductDetailsPreview

    Editor->>EditComponent: Render Product Details Block
    EditComponent->>EditComponent: Check hasInnerBlocks & wasBlockJustInserted
    alt Block has inner blocks or was just inserted
        EditComponent->>EditComponent: Render inner blocks container (with template if just inserted)
    else
        EditComponent->>LegacyProductDetailsPreview: Render legacy preview (hideTabTitle: true)
    end
Loading

"""


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f538704 and cf1d519.

📒 Files selected for processing (1)
  • plugins/woocommerce/client/blocks/assets/js/blocks/product-details/edit.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/woocommerce/client/blocks/assets/js/blocks/product-details/edit.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Jul 16, 2025

Size Change: +1.39 kB (+0.02%)

Total Size: 5.86 MB

Filename Size Change
./plugins/woocommerce/client/blocks/build/product-details.js 3.67 kB +1.21 kB (+49.37%) 🚨

compressed-size-action

Copy link
Contributor

github-actions bot commented Jul 16, 2025

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming <!-- wp:woocommerce/product-details {"className":"is-style-minimal"} /--> stays as the legacy block:

imatge

From the testing steps:

See the Accordion layout is used for the newly inserted block.
Reload the editor again.
Delete the Accordion Group block inside Product Details.
See the legacy editor preview of the previous version of the block rendered.

This doesn't work if I don't reload the editor, but I guess that's expected, right?

Testing environment
  • WordPress 6.8.1 local dev environment
  • Plugins: WooCommerce Beta Tester
  • Theme: TT5
  • Store creation: June 2025
  • Store size: small

@dinhtungdu
Copy link
Member Author

This doesn't work if I don't reload the editor, but I guess that's expected, right?

@Aljullu yes, if you just inserted the Product Details block and delete the Accordion right away, it won't show the preview. Let me update the instructions to mention that.

@dinhtungdu dinhtungdu merged commit bb7b8f1 into trunk Jul 16, 2025
36 checks passed
@dinhtungdu dinhtungdu deleted the wooplug-5015-woo-1002-products-details-block-regression-compatibility branch July 16, 2025 08:38
@github-actions github-actions bot added this to the 10.1.0 milestone Jul 16, 2025
dinhtungdu added a commit that referenced this pull request Jul 16, 2025
jorgeatorres pushed a commit that referenced this pull request Jul 21, 2025
…d for existing blocks (10.0) (#59698)

* Product Details: prevent the default template to be auto applied for existing blocks (#59691)

* fix: bring the Show tab title setting back for legacy version

* fix: block validation error

* fix: preserve default wide align for legacy block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Woo 10.0.2 > products details block > regression > compatibility layer is not trigered
2 participants