Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-85592

Mobile Navigation: Multiple Sub-Menus expand/collapse simultaneously

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.5.4
    • Navigation, Themes
    • None
    • MOODLE_405_STABLE

      When having sub-menus inside the primary navigation, and the viewport is narrow enough to show the navigation inside the left drawer, clicking on one sub-menu toggles multiple sub-menus simultaniously.

      We extend the primary navigation using hooks, similar to this (sorry, the formatting is somehow borked):

      function extend_navigation(\core\hook\navigation\primary_extend $hook): void {
          $nav = $hook->get_primaryview();    $submenua = $nav->add('Submenu A', null, navigation_node::TYPE_CONTAINER, null, 'suba');
          $submenua->add('abc', 'https://example.org');    $submenub = $nav->add('Submenu B', null, navigation_node::TYPE_CONTAINER, null, 'subb');
          $submenub->add('xyz', 'https://example.org');
      } 

      I looked into the rendered HTML, where each sub-menu node has id="drop-down-"; essentially, they all have the same ID, which the responsible JS most likely needs to decide which menu to toggle.

      It looks like there is something missing from the ID. Checking out theme/boost/templates/primary-drawer-mobile.mustache I find this: id="drop-down-{{sort}}"

      Interestingly, sub-menus created by using the custommenu setting are not affected by this bug, for example:

      Some Menu
      -example a|https://example.org
      Some Other Menu
      -example b|https://example.org

      These menus do have their IDs set properly, though.

            Unassigned Unassigned
            smeikx Alex Kremser
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.