-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Unregistering core/site-logo block crashes editor when editing Patterns #63208
Comments
Thanks for the report. I was able to reproduce this issue too. This issue does not occur in WP6.5. It does occur in WP6.6 RC2 and the latest Gutenberg. ae49830e0d2bf1951071897345b270b6.mp4 |
Flagging you all since this appears to be an extensibility regression: @fabiankaegy @colorful-tones @ellatrix @vcanales |
The following changes seem to fix the critical issue, but may not be ideal. Perhaps @aaronrobertshaw knows more about this part of the code? diff --git a/packages/block-editor/src/components/global-styles/use-global-styles-output.js b/packages/block-editor/src/components/global-styles/use-global-styles-output.js
index 6756398708..41d6970d03 100644
--- a/packages/block-editor/src/components/global-styles/use-global-styles-output.js
+++ b/packages/block-editor/src/components/global-styles/use-global-styles-output.js
@@ -671,7 +671,7 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
}
const variationSelector =
blockSelectors[ blockName ]
- .styleVariationSelectors?.[ variationName ];
+ ?.styleVariationSelectors?.[ variationName ];
// Process the variation's inner element styles.
// This comes before the inner block styles so the |
🤞 this issue is just due to a missing |
Thanks for the ping 👍 It does look like I missed the optional chaining operator there, working under the impression the block nodes would match the available blocks. Given that isn't the case the proposed fix is along the right lines. This issue also shows that a variation's inner blocks could also be deregistered triggering a similar error a few lines down. I'll put together a fix in a moment. |
A fix following Aki's suggestion is available in #63252. |
Description
When using javascript to unregister the core/site-logo block, and trying to add/edit a Pattern, the editor crashes with the following error: TypeError: Cannot read properties of undefined (reading 'styleVariationSelectors')
Step-by-step reproduction instructions
Enqueue the following javascript:
Attempt to add or edit a Pattern. The editor crashes and lets you copy the error, which is:
TypeError: Cannot read properties of undefined (reading 'styleVariationSelectors')
Screenshots, screen recording, code snippet
No response
Environment info
WP 6.6-RC-2. (I have confirmed the same behavior on 6.6-RC-1, but I am quite confident that this did not crash on the early Beta I tested, and it definitely doesn't crash on 6.5.5)
No Gutenberg Plugin
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: