This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Single Product Block > Ensure the Product Summary and Title are always rendered with the correct context independent of their position #9968
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ed independent of their position in the editor.
woocommercebot
requested review from
a team and
danieldudzic
and removed request for
a team
June 22, 2023 17:35
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. |
nefeline
added
type: bug
The issue/PR concerns a confirmed bug.
block: single product
Issues related to the single product block.
labels
Jun 22, 2023
Size Change: 0 B Total Size: 1.17 MB ℹ️ View Unchanged
|
4 tasks
albarin
approved these changes
Jun 23, 2023
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.
Works great! Thanks for working on this! 👏
… restored for the post title and excerpt blocks.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
block: single product
Issues related to the single product block.
type: bug
The issue/PR concerns a confirmed bug.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #9967
This fix ensures both the Product Summary and Product Title blocks are always rendered with the correct context on the front end, independent of their position in the editor.
We already had a logic in place to prevent this from happening, but curiously, it wasn't working as expected under certain conditions.
Upon further investigation, it was possible to verify the issue occurred exclusively when one of these two blocks (either the Product Title or the Product Summary) was placed as the last inner block within the Single Product block.
This issue happens because the global
$post
variable (overridden in thereplace_post_for_single_product_inner_block
method) is restored to its original value before the last block is rendered. In other words: any block depending on this global variable update to function placed in the last position would not benefit from the fix.To solve this problem, the following changes were made:
$post
variable override hooked to'render_block_context'
(isolated to the relevant blocks)wp_reset_postdata()
to a new dedicated method hooked to the filters triggered right before generating the render output for both thecore/post-title
andcore/post-excerpt
blocks (the product title and product summary are variations of these two blocks).Screenshots
User Facing Testing
WooCommerce Visibility
Performance Impact
Changelog