Repository navigation
Don't try and render unstable location if Nav block has ID - #36863
Merged
getdave merged 4 commits intoNov 26, 2021
Merged
Conversation
getdave
commented
Nov 25, 2021
getdave
marked this pull request as ready for review
November 25, 2021 14:26
adamziel
approved these changes
Nov 25, 2021
Contributor
|
Looks good to me, but cc-ing @talldan who might have more context here. |
34 of 38 tasks
scruffian
approved these changes
Nov 25, 2021
scruffian
left a comment
Contributor
There was a problem hiding this comment.
This solves the problem for me.
scruffian
reviewed
Nov 25, 2021
getdave
commented
Nov 26, 2021
…as long as there are items at that location.
Contributor
|
I added a commit to address #36865 So the priority is:
|
getdave
force-pushed
the
fix/nav-block-unstable-location-for-universal-themes
branch
from
November 26, 2021 09:58
02079cc to
c6fc6da
Compare
scruffian
reviewed
Nov 26, 2021
| ! array_key_exists( 'navigationMenuId', $attributes ) && | ||
| ! empty( gutenberg_get_menu_items_at_location( $attributes['__unstableLocation'] ) ) | ||
| ) { | ||
| $menu_items = gutenberg_get_menu_items_at_location( $attributes['__unstableLocation'] ); |
Contributor
There was a problem hiding this comment.
There is now an inefficiency here as we are calling gutenberg_get_menu_items_at_location twice...
Contributor
Author
There was a problem hiding this comment.
Let's follow up here.
getdave
deleted the
fix/nav-block-unstable-location-for-universal-themes
branch
November 26, 2021 12:45
This was referenced Nov 26, 2021
Closed
noisysocks
pushed a commit
that referenced
this pull request
Dec 6, 2021
* Don't try and render unstable location if Nav block has ID * Reinstate condition for empty inner blocks * Lint * Show the unstableLocation menu items even if there are inner blocks, as long as there are items at that location. Co-authored-by: Adam Zieliński <adam@adamziel.com> Co-authored-by: Ben Dwyer <ben@scruffian.com>
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
We learnt in Automattic/themes#5086 that if you are using a Universal Theme the Nav block can end up rendering nothing even though there are items added in the Site Editor.
Since the Navigation block now stores its inner "items" in a CPT
there a no longer an inner blocks stored directly on the block itself.the only time when inner blocks are stored directly on the block is if the block is part of a pattern. If you are working with the Nav block within the editor your changes are saved to the CPT and not as inner blocks.If
__unstableLocationis defined (universal Themes) then even if you add "items" to the Nav block in the Site Editor, the front end rendering code will try and render the menu at__unstableLocation. If such a Menu does not exist then nothing is shown. This is due to the conditional:gutenberg/packages/block-library/src/navigation/index.php
Line 259 in f439aef
This is wrong. The contents of the Site Editor should take precedence. The reason they aren't is that the code is expecting the contents of the Nav block to be the inner blocks whereas this can now also be indicated by the presence of a
navigationMenuIdattribute (which references thewp_navigationCPT where the nav "items" are stored).Addresses Automattic/themes#5086
Closes #36865
How has this been tested?
On trunk
On this PR
Screenshots
Types of changes
Checklist:
*.native.jsfiles for terms that need renaming or removal).