-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update Callers to handle when getBlockType return undefined #35097
Update Callers to handle when getBlockType return undefined #35097
Conversation
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 taking a look @amustaque97! I left a few notes.
packages/block-editor/src/components/block-tools/block-selection-button.js
Outdated
Show resolved
Hide resolved
This PR is part of #34462 To manually test this, create a new post, and in the code editor add:
Go back to code view, and we should see the missing block: Unregister the missing block type in console:
Try doing some actions like going to code view or trying to click the missing block. Theoretically the editor should not WSOD, or throw a JS error (from any of the areas this PR has updated). |
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.
This one just needs one more change and it should be good to land! Sorry for the delay @amustaque97
I also verified in manual testing that we didn't see any errors related to code changes here when unregistering the missing blockType
@gwwar, I have addressed review comments. Please take a look once you get some time. |
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 your work here @amustaque97! I'll land this once we get a clean test run ✅
Description
In most cases we either need to check if blockType is truthy before using it, or use optional chaining if it makes sense. eg
const icon = blockType?.icon;
How has this been tested?
Testing Instruction can be found here #34346 (comment)
Screenshots
Types of changes
Fix
Checklist:
*.native.js
files for terms that need renaming or removal).cc @gwwar