#39101 closed defect (bug) (fixed)
Customize: edit shortcuts for custom menu widgets do not work
Reported by: | celloexpressions | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.7.1 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | Customize | Keywords: | has-patch commit fixed-major |
Focuses: | Cc: |
Description
Custom menu widgets contain associated menu partials, which also get shortcuts. This has a few issues:
- There are two shortcut icons, one for the menu and one for the widget.
- The menu shortcut doesn't work. Menu partials look for the associated menu location control, but menus displayed via widgets are not in a menu location.
- Depending on the theme, if the widget does not have a title the menu shortcut will likely be displayed on top of the widget shortcut. Since the menu shortcut doesn't work and the widget shortcut is essentially hidden, the shortcuts appear broken and essentially do nothing (unless you navigate to the widget shortcut with the keyboard).
We should either prevent the menu within a custom menu widget from getting an edit shortcut, or hide that icon with CSS. The widget shortcut is more appropriate in that the widget is the "location" of the menu, and the widget control links to edit the menu similarly to the menu location controls.
Attachments (3)
Change History (18)
This ticket was mentioned in Slack in #core-customize by celloexpressions. View the logs.
8 years ago
#4
@
8 years ago
- Keywords has-patch added; needs-patch removed
@sanket.parmar That sounds like it would indeed work! But I think it might also prevent custom menu widgets from using partials at all? (I maybe wrong.)
I attached a javascript patch which should prevent nav menus within widgets from getting their own shortcuts. Please let me know if it works for you!
#5
@
8 years ago
- Keywords commit added
- Owner changed from sirbrillig to westonruter
- Status changed from assigned to reviewing
39101.diff looks good and works for me. Might want to add an inline comment explaining that it's disabled because the associated widget partial should take precedent, otherwise should be ready for commit.
This ticket was mentioned in Slack in #core by jorbin. View the logs.
8 years ago
#7
@
8 years ago
@sirbrillig @celloexpressions I found the underlying problem was that the showControl
logic was only accounting for wp_nav_menu()
instances that referenced a given theme_location
. The Custom Menu widgets never have a theme_location
but rather instead refer to a given menu
by ID directly. So the fix is just to add support for menu
if theme_location
is not set. This will also fix the edit shortcuts for any wp_nav_menu()
instances that use menu
in places other than the Custom Menu widget. See 39101.3.diff.
This new patch also fixes an issue where showControl
would end up focusing on the last control that it found to be associated with a given setting. In this new patch, it will first sort the controls by their priority to then focus on the one that hast the priority with the smallest number, and thus the controls that appear at the top. For nav menus this ensures that the focus is given to the nav menu name control as opposed to the last checkbox control in the nav menu section.
Please confirm and I'll go ahead and commit.
#8
@
8 years ago
@westonruter nice sleuthing! Confirmed that that fixes the bug, in that it allows the edit shortcut for menus in widgets to work again.
That said (and your patch should be committed regardless), I wonder which is the better experience for users?
Clicking on the (fixed) menu shortcut brings up the editor for that menu.
Clicking on the widget shortcut brings up the widget settings, which allow changing which menu is displayed there.
It seems to me that both could be what a user might be looking for, but obviously we can only allow one. Since you can click the "Edit Menu" button to get from the widget settings to the menu settings and not the other way around, I suggest we hide the menu shortcut anyway, but I'm open to a dissenting opinion.
This ticket was mentioned in Slack in #core-customize by sirbrillig. View the logs.
8 years ago
#11
@
8 years ago
- Keywords fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
Re-opening for 4.7.1
@sirbrillig Good questions you're raising. I don't think it particularly hurts that there is two shortcuts for the two separate entities. On that note, one thing I am noticing is that the edit shortcut isn't appearing for the wp_nav_menu()
instance when first adding the Custom Widget to the page. Likewise, the edit shortcut goes away for the wp_nav_menu()
after making a change to the Custom Menu widget. So there seems to be an issue with nested partials and edit shortcuts.
Hi @celloexpressions ,
What if we don't load an edit icon for custom menu widgets. I mean on https://core.trac.wordpress.org/browser/tags/4.7/src/wp-includes/class-wp-customize-nav-menus.php#L1298 line we add one extra condition to check
fallback_cb
is not empty ( i.e.,! empty( $args->customize_preview_nav_menus_args['fallback_cb'] )
). This way the edit icon will not load for custom menu widgets.Let me know your thoughts.