-
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
Section Styles: Fix error when blocks are deregistered #63252
Section Styles: Fix error when blocks are deregistered #63252
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +6 B (0%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
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 quick fix 🙇 These changes make sense to me.
Appreciate the lightning-fast review @t-hamano ⚡ Once the tests pass, I'll get this merged and address anything else in a further follow-up. |
Co-authored-by: aaronrobertshaw <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: ndiego <[email protected]> Co-authored-by: MadtownLems <[email protected]>
I just cherry-picked this PR to the wp/6.6 branch to get it included in the next release: ed3f1d8 |
Co-authored-by: aaronrobertshaw <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: ndiego <[email protected]> Co-authored-by: MadtownLems <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: ndiego <[email protected]> Co-authored-by: MadtownLems <[email protected]>
Fixes: #63208
What?
Adds optional chaining to retrieval of variation selectors to prevent an error and editor crash when a block has been deregistered via JS.
A better long-term fix will be to refactor the block style variations hook so that the block types and selectors retrieved there can't be stale. This PR is the quickest fix that addresses the issue in time for the final 6.6 RC. It will also make any future refactor more robust as well.
Props to @t-hamano for isolating the cause of the error 🙇
Why?
How?
.
-->?.
Testing Instructions
trunk
core/site-logo
,core/image
etc.wp.blocks.unregisterBlockType( 'core/image' );
Bonus Points
core/image
blockPHP group block style variation snippet
Screenshots or screencast
Screen.Recording.2024-07-09.at.12.34.24.AM.mp4
Screen.Recording.2024-07-09.at.12.35.15.AM.mp4