Skip to content

Conversation

@chihsuan
Copy link
Member

@chihsuan chihsuan commented Jun 16, 2022

All Submissions:

Changes proposed in this Pull Request:

This PR fixes a Uncaught TypeError:

Uncaught TypeError: Cannot read properties of undefined (reading 'innerHTML')
    at getTinyMceValue (product-tour.js?ver=6.7.0:93:220)

It seems that #tinymce is loaded after we call getTinyMceValue. This only happens

  • when a user uses the text editor by default
  • the first time that a user switches editor to TinyMce

I think a way to fix it is to use MutationObserver, but I don't think it's worth it. So just check the type and return an empty string if it's undefined.

I also changed all document.querySelector... as ...; to document.querySelector<...> to avoid null exceptions.

How to test the changes in this Pull Request:

  1. Install and activate WCA Test Helper
  2. Go to Tools > WCA Test Helper > Features
  3. Enable experimental-product-tour
  4. Go to Tools > WCA Test Helper > Experiments
  5. Add woocommerce_products_tour to treatment
  6. Go to WooCommerce > Home > Add my products > Start with a template > Physical product
  7. Observe that spotlight tour is displayed and dismiss it.
  8. Switch to the text tab for product description
  9. Reload the page
  10. Observe that spotlight tour is displayed again
  11. Click "next" button
  12. Switch to the Visual tab
  13. Observe that the spotlight tour is still shown and no typeError in dev tools.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you created a changelog file for each project being changed, ie pnpm changelog add --filter=<project>?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@github-actions github-actions bot added focus: react admin plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Jun 16, 2022
@chihsuan chihsuan self-assigned this Jun 16, 2022
@chihsuan chihsuan requested a review from a team June 16, 2022 04:46
@chihsuan chihsuan marked this pull request as ready for review June 16, 2022 04:47
@botwoo
Copy link
Collaborator

botwoo commented Jun 16, 2022

📊 Test reports for this pull request have been published and are accessible through the following links:

Latest commit referenced in the reports: Add changelog b2c4ae9
This comment will automatically be updated with the latest referenced commit when you push new changes to this pull request.


Visit the WooCommerce Test Reports homepage to view all published reports. See the FAQs page if you're having problems accessing them.

Copy link
Contributor

@moon0326 moon0326 left a comment

Choose a reason for hiding this comment

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

Thank you for the quick fix! Yeah, I agree that MutationObserver might be an overkill. The change looks good to me and tested well 👍 🚀

@chihsuan chihsuan merged commit ea19423 into trunk Jun 16, 2022
@chihsuan chihsuan deleted the fix/tour-kit-undefined-error branch June 16, 2022 06:02
@github-actions github-actions bot added this to the 6.7.0 milestone Jun 16, 2022
@github-actions
Copy link
Contributor

Hi @chihsuan, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the release: add testing instructions label

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.

4 participants