Opened 9 years ago
Closed 9 years ago
#35362 closed defect (bug) (fixed)
Empty `items_wrap` `wp_nav_menu` randomly breaks customizer
Reported by: | ojrask | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Customize | Keywords: | has-patch |
Focuses: | Cc: |
Description
Assuming a navigation menu is generated in the frontend using wp_nav_menu
and setting the argument items_wrap
to an empty string (''
).
Then when toying around with the menu and its items inside the customizer, the customizer breaks randomly and begins duplicating the whole menu recursively in the preview pane until the browser crashes or is forced to quit.
If the items_wrap
argument is removed or changed the problem disappears.
Tested on WP 4.4 with a custom theme.
Attachments (7)
Change History (22)
#2
@
9 years ago
Hey,
So sorry, I misunderstood the issue details from a team mate. Yes, the container is set to false
and items_wrap
contains only %3$s
.
The menu began working normally after the default items_wrap
was used and container
was still false
. Other menu args are fallback_cb => false
and theme_location => foobar
.
It seems that the issue is the with the "fast refresh" system as you mentioned.
#3
@
9 years ago
- Keywords needs-patch added; reporter-feedback removed
- Milestone changed from Awaiting Review to 4.5
#5
@
9 years ago
- Keywords has-patch added; needs-patch removed
I believe the primary fix here is to just block partial refresh for nav menus that have container
and items_wrap
args that both lack a start tag, as in 35362.0.diff. Granted this will then still fail if the one of the elements does contain a start tag but then lacks having a class attribute. I'm working on a more robust solution in #27355.
#6
@
9 years ago
@ojrask the Customize Partial Refresh plugin should now include the fix for this. Can you test for the issue with the plugin active and on the latest nightly (4.5-alpha)?
#7
@
9 years ago
- Keywords needs-patch added; has-patch removed
There is a different problem now with the merge of selective refresh. No longer will the menu get duplicated. Now the problem is that when a wp_nav_menu()
is called in a way that it cannot be selective-refreshed, then it will fail to get a full page refresh. This means that changes to such menus currently cannot be previewed in 4.5-beta2.
Some of the logic removed in [36586] may need to be restored, specifically the logic which kept a tally of the total number of wp_nav_menu()
calls not just those which can use selective refresh.
#9
@
9 years ago
@ojrask are you able to do some testing on this latest patch to ensure that it works with your configuration?
#10
@
9 years ago
Discovered an issue: In Twenty Fifteen with the Social Links Menu assigned to no menu, assign a nav menu to that location and notice the preview not update to show the nav menu.
#11
@
9 years ago
In 35362.3.diff:
- Do fallback behavior if no menu is associated with the nav menu instance partial.
- Do fallback behavior if newly-rendered menu is empty
- Do full refresh if a nav_menu_locations[] is changed for a location which doesn't exist in the preview
#12
@
9 years ago
Another edge case discovered:
- Create a Custom Menu widget and assign a menu to this widget that lacks any menu items.
- Add a menu item to this widget and notice that the menu is not updated in the widget.
#13
@
9 years ago
35362.4.diff: Do partial fallback when adding nav menu items to empty menus
Another edge case:
- Create nav menu widget and assign to a non-empty nav menu
- Change the widget's assigned nav menu to one that lacks any menu items.
- Add nav menu item to the empty nav menu
- No changes are seen.
#14
@
9 years ago
35362.5.diff Fix aforementioned edge case by ensuring that wp_nav_menu()
calls made inside of partials get communicated back and made part of the manifest of instances on the page so that the full-page refresh fallback logic will know about them.
@ojrask: Thanks for the report.
I don't see how setting
items_wrap
to an empty string would work at all in the first place. When I try, the menu stops appearing altogether.The default value for
items_wrap
I see is<ul id="%1$s" class="%2$s">%3$s</ul>
. This then is used inwp_nav_menu()
via:So if the
items_wrap
is empty, then no menu will be constructed at all from the format string.I am able to remote the wrapper element by setting
items_wrap
to'%3$s'
.Are you removing the
container
in addition to theitems_wrap
? You could then actually be noticing what has been described here: https://make.wordpress.org/core/2015/07/29/fast-previewing-changes-to-menus-in-the-customizer/#comment-26503