-
Notifications
You must be signed in to change notification settings - Fork 219
[Product Collection] Fix: HTML entity decoding for product names in Hand-Picked Products #11927
Conversation
…ntrol In the Hand-Picked Products control within the product-collection inspector controls, a function for decoding HTML entities in product names has been added. - A new utility function `decodeHTMLEntities` has been implemented. This function decodes HTML entities in a string, ensuring that special characters are correctly displayed in their human-readable form. - The `transformTokenIntoProductName` function has been updated to utilize `decodeHTMLEntities`. Now, when a product name is fetched (either directly as a token or via a product ID), the HTML entities within the name are decoded. - This enhancement ensures that product names containing characters like ampersands or other HTML entities are accurately displayed in the UI. This change improves the readability and accuracy of product names within the Hand-Picked Products control, enhancing the user experience for store managers using WooCommerce Blocks.
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: -1 B (0%) Total Size: 1.61 MB
ℹ️ View Unchanged
|
This commit updates the `HandPickedProductsControl` component. Specifically, the user-facing label for product selection has been changed from 'Pick some products' to 'Hand-picked Products'. Additionally, the `__experimentalShowHowTo` property has been added with a `false` value, to hide description. Corresponding changes have been made in the E2E test file `product-collection.block_theme.spec.ts`, where the filter name is updated to match the new label.
* @param {string} str - The string containing HTML entities. | ||
* @return {string} - The decoded string. | ||
*/ | ||
function decodeHTMLEntities( str?: string ) { |
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.
Hey @imanish003 I think we already have a function that does this, check here. I think we should probably used that.
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.
Good catch @albarin. Thanks 🙏 Let me quickly change the code.
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.
Made the changes in 70ea5f1
…tities` Rationale: - The shift to `@wordpress/html-entities` aligns with standard WordPress practices, ensuring consistency across the platform. - Enhances maintainability by relying on a well-supported library rather than custom code. - Simplifies the codebase by removing a redundant utility function. This change enhances the robustness of our code and aligns with best practices in WordPress development.
…m/woocommerce/woocommerce-blocks into fix/html-entities-in-product-name
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 for the update! LGTM 🚀
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 for a quick fix 🚀 I tested some other entities as well, works as expected!
What
I've implemented three updates in this PR:
Hoodie – Black
. The screenshot below illustrates this issue.Fixes #
Why
These changes were proposed by @manospsyx on Slack (p1700652774848299-slack-C05UMTA7W0P).
Testing Instructions
Please consider any edge cases this change may have, and also other areas of the product this may impact.
Checking the Hyphen Representation:
–
to the name of any product, likeHoodie - Black
.Verifying Label Update:
Screenshots or screencast
WooCommerce Visibility
Required:
Checklist
Required:
[type]
label or a[skip-changelog]
label.Conditional:
[skip-changelog]
label is not present).Changelog