Fix non existent menu handling in nav block#36507
Merged
Conversation
|
Size Change: -26 B (0%) Total Size: 1.09 MB
ℹ️ View Unchanged
|
aristath
approved these changes
Nov 24, 2021
Member
aristath
left a comment
There was a problem hiding this comment.
Great improvement!
Looks good to me 👍
Contributor
Author
|
Thanks for reviewing and merging, I'd forgotten about this 😄 |
noisysocks
pushed a commit
that referenced
this pull request
Nov 29, 2021
* Fix missing menu detection * Remove warning state, just fall back to placeholder
This was referenced Dec 8, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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).