Skip to content
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

Fix: handle undefined templateSlug in Product Collection tracking utils #47504

Conversation

imanish003
Copy link
Contributor

@imanish003 imanish003 commented May 15, 2024

Changes proposed in this Pull Request:

The modification introduces a check for templateSlug before attempting to access its properties or use it in further logic. This change addresses a bug that manifested when users tried to edit Product Collection block in Sync Pattern, resulting in a JavaScript error because templateSlug could be undefined.

Closes #47502

How to test the changes in this Pull Request:

  1. Go to "Products by category" template & add product collection block to it.

  2. Create a sync pattern with Product Collection block inside it.

  3. Select sync pattern and click on "Edit original" in toolbar as shown in screenshot below
    image

  4. Verify that the following error isn't occurring when the Sync pattern is loaded in Editor.
    image

  5. Developer only testing: Verify that you are able to reproduce this issue on trunk but not on this PR branch.

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Fix: handle undefined templateSlug in Product Collection tracking utils

Comment

The modification introduces a check for templateSlug before attempting to access its properties or use it in further logic. This change addresses a bug that manifested when users tried to edit a synchronized Product Collection block, resulting in a JavaScript error because templateSlug could be undefined.
@imanish003 imanish003 added type: bug The issue is a confirmed bug. team: Kirigami & Origami focus: FSE Issues related to Full Site Editing block: product collection Issues related to the Product Collection block labels May 15, 2024
@imanish003 imanish003 marked this pull request as ready for review May 15, 2024 12:04
@woocommercebot woocommercebot requested review from a team and kmanijak and removed request for a team May 15, 2024 12:04
Copy link
Contributor

github-actions bot commented May 15, 2024

Hi @xristos3490, @kmanijak,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@imanish003 imanish003 closed this May 15, 2024
@imanish003 imanish003 reopened this May 15, 2024
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label May 15, 2024
Copy link
Contributor

github-actions bot commented May 15, 2024

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
Member

@xristos3490 xristos3490 left a comment

Choose a reason for hiding this comment

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

Works as expected 👌

Copy link
Contributor

@kmanijak kmanijak left a comment

Choose a reason for hiding this comment

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

Works as expected. Thanks for taking care of it!

@imanish003 imanish003 merged commit 1233fb4 into trunk May 16, 2024
35 checks passed
@imanish003 imanish003 deleted the 47502-issue-error-when-editing-a-synced-pattern-with-product-collection-block branch May 16, 2024 05:47
@github-actions github-actions bot added this to the 9.0.0 milestone May 16, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label May 16, 2024
@alvarothomas alvarothomas added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels May 17, 2024
@alvarothomas alvarothomas added the status: analysis complete Indicates if a PR has been analysed by Solaris label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
block: product collection Issues related to the Product Collection block focus: FSE Issues related to Full Site Editing needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Kirigami & Origami type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue: Error when editing a synced pattern with Product Collection block
4 participants