-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix non existent menu handling in nav block #36507
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
Conversation
|
Size Change: -26 B (0%) Total Size: 1.09 MB
ℹ️ View Unchanged
|
Mamaduka
left a comment
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 |
|---|---|
![]() |
![]() |
aristath
left a comment
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_navigationpost 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_navigationdoesn't exist the user ends up with an empty block that can't be saved.This fixes both of those issues:
getEntityRecordto determine if an entity exists instead ofgetEditedEntityRecord.getEditedEntityRecordalways returns an object once resolved which makes it hard to tell if an entity is missing.getEntityRecordreturnsundefined. This fix is in theuseNavigationMenuhook.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?
navigationMenuIdto 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.jsfiles for terms that need renaming or removal).