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 221
Fix the order of enqueued scripts in the Mini-Cart block #9749
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
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: 0 B Total Size: 1.1 MB ℹ️ View Unchanged
|
6e5bd01
to
17816e9
Compare
roykho
approved these changes
Jun 7, 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.
Tested as advertised. Good job!
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
block: mini-cart
Issues related to the Mini-Cart block.
skip-changelog
PRs that you don't want to appear in the changelog.
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.
In #9586, we introduced a fix that made that if a script was already enqueued, it would not be added to the list of scripts to lazy load by the Mini-Cart block. That caused some issues so we needed to revert it in #9649.
The reason of the issues was that the order the code was running caused
wc-settings
to appear as enqueued even though it was not. The reason was that:wc-settings
, that was required to make sure we include some PHP constants which are used by this script.woocommerce-blocks/src/BlockTypes/MiniCart.php
Line 73 in c378f92
wc-settings
and its dependencies because it had been enqueued in step 1.woocommerce-blocks/src/BlockTypes/MiniCart.php
Line 75 in c378f92
wc-settings
if it hasn't been enqueued by a 3rd-party, as the original idea was to lazy load it.woocommerce-blocks/src/BlockTypes/MiniCart.php
Line 230 in c378f92
The bug came from the fact that step 3 assumed
wc-settings
would be lazy loaded, but step 2 was not adding it to the array of scripts to lazy load. So in the fronted,wc-settings
and its dependencies were missing, causing the Mini-Cart to crash.To solve it, I changed the order, so step 3 runs before step 2:
wc-settings
.wc-settings
(if it hasn't been enqued by a 3rd-party).So basically, what this PR does:
wc-settings
is enqueued or not (f3322f4).Testing
Automated Tests
User Facing Testing
WooCommerce Visibility