Menu item checkbox "Show as expanded" not working properly

Created on 17 May 2019, about 5 years ago
Updated 5 September 2023, 10 months ago

I have a main menu with 2 levels. If menu item on the first level doesn't have "Show as expanded" checkbox checked submenu items shouldn't be shown. This works fine only when this menu item parent is not active.
Let say that I have a menu structure like this:
- menu1
-- submenu1
-menu2
-- submenu2

If menu1 has "Show as expanded" unchecked and we are on the menu2 page, then submenu1 menu item will not be shown. But if we open the menu1 menu item, the submenu1 menu item is also shown, but it shouldn't be.

✨ Feature request
Status

Needs work

Version

9.5

Component
Menu system  →

Last updated 5 days ago

Created by

🇸🇮Slovenia icurk

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States aaronpinero

    I'd like to see this issue reopened. I don't believe the original issue was solved in that, while the system may work as designed, it does not work as desired. The problem is that, the way it works now, menu option appears expanded when it is the currently selected item even if you have unchecked the "show as expanded" option in the menu link configuration. This is true even if in your menu block configuration you have unchecked the "expand all menu options" option. The only way to keep the selected menu option from showing as expanded is to restrict the menu levels. This makes it impossible to have a menu where you want one option to expand but another option to not expand.

    Here is my specific case:

    I have a main menu. Two of the options in the main menu have child menu options. I want one to expand and the other to not expand. In the menu configuration, I checked "show as expanded" for the first menu option and left this unchecked for the second menu option.

    For my menu block, I have configured it to show 2 levels to display and I have left the expand all menu links unchecked.

    The result is that everything works fine except when the second menu option is the select menu option. In that case, even though I have not configured the option to show as expanded, it shows as expanded anyway because it's the selected option.

    What I want is for this option to never show as expanded in this block, even if it's selected.

    This could be done by respecting the existing "show as expanded" configuration. Or, perhaps there could be a menu setting that determines if selected menu options appear expanded.

  • 🇺🇸United States aaronpinero

    The original patch posted by @icurk didn't apply cleanly for me (I'm using Drupal 9.5.3) but I was able to update the patch to work. I will try to add this to the issue. The patch appears to resolve the issue for me in that the menu respects the unchecked "show as expanded" option even when the option is the currently selected option.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India BhumikaVarshney Delhi

    As per comment #13, I followed the same steps added for the specific case to reproduce the same.

    Created 2 menus

    Home
    -- home 1
    Home 3
    --home 4

    Home menu -> Checked Show as expanded
    Home 3 -> unchecked Show as expanded

    For my menu block, I have configured it to show 2 levels to display and I have left the expand all menu links unchecked.

    So after all this configuration, Second Menu is not expanded as expected in the feature request without applying any patch.
    I have attached the screenshot for all the configurations.

    Thank You!

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    When the issue was reopened should of have been tagged with an issue summary update with why this should remain open and proposed solution.

    Also will need test coverage.

  • 🇮🇳India Nishant2312

    In accordance with Comment #13, I meticulously followed the provided steps to reproduce the issue.

    Here's a summary of the steps I took:

    1. I created two menus:
    - Menu 1:
    - Home
    - test
    - Menu 2:
    - Home 1
    - Home 1

    2. Within "Menu 1," I marked "Show as expanded," and in contrast, I unchecked "Show as expanded" for "Home 1" within "Menu 2."

    3. For my menu block configuration, I opted to display up to 2 levels and intentionally left the "Expand all menu links" option unchecked.

    Despite meticulously configuring the menus and the menu block, the behavior of the second menu did not expand as expected, aligning with the feature request. Your prompt assistance in resolving this matter is greatly appreciated. Thank you!

    As of now, it is working as designed and there is no need to apply the patch.

  • 🇺🇸United States aaronpinero

    @Nishant2312 based on your description, I do not think you configured your menu correctly to illustrate the problem. Perhaps this could be better explained over a screen sharing session on Slack. I would be happy to schedule something if you feel it would be helpful.

Production build 0.69.0 2024