If selected and this menu link has children, the menu will always appear expanded if "Show as Expanded" is checked. This is correct, of course. As it says underneath the option, "If selected and this menu link has children, the menu will always appear expanded."

But if you uncheck it, the sub-menu never expands, even with the parent menu item active. Shouldn't it expand no matter what if the parent item is active? Or is there an option I'm missing? Surely it's not all or nothing? It worked correctly in Drupal 6.

This is a custom menu I have displayed in the sidebar.

Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rbtstudio’s picture

Version: 7.0-beta2 » 7.0-beta3
Issue tags: +menu, +expandable, +sidebar, +submenu hidden

I'm updating jazzdrive3's post to the current beta version that I'm using from the original beta2 to beta3 as it still appears to be an issue.

I've also created a new sidebar menu with two links, the second of which has six child links. When "Show as Expanded" is checked, just as jazzdrive3 stated, all child links are shown as would be expected. When the checkbox is left blank, all the child links are hidden but do not appear when the parent link is clicked. I'm very new to Drupal and I wouldn't be surprised if I've missed a setting somewhere, but I'm trying to be thorough and have yet to find any said setting.

I don't have a 6.0 version to compare it to.

Any suggestions? Am I missing something? Thanks so much.

taslett’s picture

Status: Active » Closed (works as designed)

Hi Guy's,
I think this is actually expected behavior.
It's up to the theme or a menu module to handle the showing of collapsed menu items.

jazzdrive3’s picture

Status: Closed (works as designed) » Active

So the expected behavior is completely different from Drupal 6, even though its the exact same setting and wording?

This is just the default menu system with regular menus.

When a menu item is active, it's giving it a "collapsed" class, when it shouldn't be. And the secondary link are not even printed out. The class should be "expanded" and the links should be printed out.

This is a clear bug.

I assume that, now that some of the expanded menus are being shown as administration overlays, that this was overlooked. But there is definitely something wrong with the way its handling expanded menus.

taslett’s picture

Hi jazzdrive3,
Glad you reopened this.
I overlooked that the menu you were using was a custom menu in the sidebar.
In D6 in Garland the collapsed menus show the next level down in the menu tree if you are on a page in the active trail.
D7 if the menu item in not expanded it's children don't seem to ever get displayed.

robash’s picture

Version: 7.0-beta3 » 7.0-rc1

Quick update as the issue is still present in rc1.

amanaplan’s picture

subscribing

Alex UA’s picture

Title: Sub-Menu does not expand at all unless "Show as Expanded" is checked » Custom menus do not expand past top level menu items in blocks
Priority: Normal » Major
Issue tags: +Needs usability review, +D7UX usability, +user interface bug

I'm raising this up to major, as this is a nasty little regression for many sites. Basically, this makes it so that you cannot use custom menus for site navigation, at least not in blocks. Core menu blocks work fine.

amanaplan’s picture

googletorp’s picture

I'm reposting the stuff I found out in posting #984648: Expanding of menu items with children and breadcrumbs only work for core defined menus by default., as I didn't find this issue.

Anyways the problem is not only that the menus is not expanding but also the breadcrumb is not generated properly. I've made some SS in the mentioned issue to illustrate this.

The core problem is that Drupal will look at for a given path in the "active menus" to figure out if it's in a menu. This will trigger the expanding of the menu and the breadcrumb. The problem is that the active menus aren't really the active menus but instead a static list of Drupal core menus. The relevant code looks like this

// Retrieve a list of menu names, ordered by preference.
$menu_names = menu_get_active_menu_names();
variable_get('menu_default_active_menus', array_keys(menu_list_system_menus()));

Since there is no interface for it, the only way to alter the variable menu_default_active_menus would be to query the DB directly or define it in the settings.php file. None of those options are appealing.

What makes this tricky is that the same link can be defined in several menus. This will make it hard to figure out how we should handle possible duplicate links, as the breadcrumb is derived of the menu structure. A simple solution that could solve most of this problem could be to create an interface to define which menus are active. But I don't know the menu system very well so I hope there is a better solution to this problem than this.

fictionindustries’s picture

Yup got the same problem. Seems like a very big bug. Its also the first one I found in the new Drupal 7!

subscribing.

amanaplan’s picture

Version: 7.0-rc1 » 7.x-dev

As per Drupal.org policy, changing this issue to 7.x-dev.

timhilliard’s picture

Status: Active » Needs review
FileSize
5.25 KB

I've done quite a bit of troubleshooting for this problem and I agree with all of what googletorp has mentioned.

By activating the menu the link is able to expand, however only one link may be considered the preferred link for the path even if there are several links pointing to the same path. This means that only one link of a particular path may be expanded at any one time, this includes duplicate links in the same menu (although it could be considered unlikely for duplicate links to appear in the same menu). A big problem with this is that when a user clicks a link they will be expecting it's child links to expand, but as the link may not be the preferred link for that path it will never be able to expand and may end up getting collapsed into its parent link as it is no longer in the active trail.

The main problem here is that the 'expanded' part of the $tree_parameters are being set with the active trail rather than a list of all the parents. I have attached a patch that creates a new function called menu_link_get_all which is almost like menu_link_get_preferred except that it returns all the active links rather than just the preferred one. We are then able to build the 'expanded' part of the $tree_parameters correctly using the result of this new function.

I believe the new function could have been stripped down a bit further so that it doesn't get the whole link but rather just the parts that are needed but it seemed like the more correct way to do this was to return the whole link item the same way that menu_link_get_preferred does.

timhilliard’s picture

Forgot to mention that by creating the new function I removed the need for the items to be part of an active menu as this seems to be there primarily to calculate the active trail.

jn2’s picture

Version: 7.x-dev » 7.0-rc4

Problem still present in Drupal 7.0-rc4.

timhilliard’s picture

Version: 7.0-rc4 » 7.x-dev

this hasn't been committed therefore not fixed in rc4

timhilliard’s picture

I think before we can definitely commit this I would like to know for sure what the variable 'menu_default_active_menus' is actually used for. If this variable should be set when menus are activated then it should also be present in the new menu_link_get_all function. I would like to know what others think about this.

timhilliard’s picture

Assigned: Unassigned » timhilliard
Status: Needs review » Needs work

I think we should also wait for #402896: Introduce DrupalCacheArray and use it for drupal_get_schema() to be completed as this patches some of the code that I've fixed in the patch. I can then re-roll once this is done.

amanaplan’s picture

Turns out this is a duplicate of #942782: Custom menus never receive an active trail which seems to have more traction.

Alex UA’s picture

Status: Needs work » Closed (duplicate)

Change status...

wouterpouls’s picture

Status: Closed (duplicate) » Needs review
Issue tags: -menu, -Needs usability review, -expandable, -sidebar, -D7UX usability, -submenu hidden, -user interface bug

Status: Needs review » Needs work
Issue tags: +menu, +Needs usability review, +expandable, +sidebar, +D7UX usability, +submenu hidden, +user interface bug

The last submitted patch, menu_inc-expanding-links-968878.patch, failed testing.

xjm’s picture

Status: Needs work » Closed (duplicate)