-
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
Fix non existent menu handling in nav block #36507
Conversation
Size Change: -26 B (0%) Total Size: 1.09 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.
Works as expected. Thanks, @talldan.
Before | After |
---|---|
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.
Great improvement!
Looks good to me 👍
Thanks for reviewing and merging, I'd forgotten about this 😄 |
* Fix missing menu detection * Remove warning state, just fall back to placeholder
Description
When the
wp_navigation
post associated with a navigation block no longer exists (for example, a user deleted it using wp-admin), the block is designed to show a message:There are two problems:
wp_navigation
doesn't exist the user ends up with an empty block that can't be saved.This fixes both of those issues:
getEntityRecord
to determine if an entity exists instead ofgetEditedEntityRecord
.getEditedEntityRecord
always returns an object once resolved which makes it hard to tell if an entity is missing.getEntityRecord
returnsundefined
. This fix is in theuseNavigationMenu
hook.Note - the template part block also has this issue. The navigation block's code was copied from the template part block. I'll make an issue about this.
How has this been tested?
navigationMenuId
to be an id that doesn't exist on your site (e.g.999999
).Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).