I am using responsive_menu module on the varbase distribution which uses a bootstrap 4 based theme. The problem is that the children of the main parent menu item do not appear in the mobile off-canvas menu.

I have several parent menu items in the main navigation menu on all the pages - Home, Contact Us, Blog, News, Services

Both the mobile menu and horizontal menu block are placed in the Navbar Collapsible region of the theme.

The services menu item has 3 levels of children

Services (parent) > Business Services (first child) > Commercial Property (second child) > several commercial property services (third level children.

Similarly

Services (parent) > Individual Services (first child) > Residential Property (second child) > several residential property services (third level children.

I can see and tap all parent level items in the mobile off-canvas menu. However, when I tap Services parent menu item (which has children as described above) it is blank. No children are visible at all

I have attached two screenshots to help understand the issue.

I am not sure what could be the problem.

Comments

aanjaneyam created an issue. See original summary.

tanc’s picture

In your Parent-View-mmenu.png screenshot, what is the downwards facing arrow next to services? Can you paste the HTML for that part of the menu tree in a comment here?

aanjaneyam’s picture

The downward-facing arrow appears when I provide a link URL to Services menu item. It disappears when I provide . I believe it is normal as the arrow would serve as an indication that there are children of that parent menu item. However, I believe that downward facing arrow should only appear in the Horizontal menu as the off-canvas mobile menu already has another arrow on the right to indicate that it has children. The downward arrow appears because I have added has-child class to the menu item to show that it has children but somehow it also appears in mobile menu also.

I will try to use web developer in firefox to extract the relevant HTML and paste it.

EDIT: I removed the has-child class and the arrow in the horizontal menu has disappeared but somehow the arrow is still there in the mobile menu.

aanjaneyam’s picture

StatusFileSize
new13.65 KB
new13.5 KB

I have uploaded the HTML for the main navigation applied to both the mobile and horizontal menus.

aanjaneyam’s picture

StatusFileSize
new8.05 KB
tanc’s picture

Thank you for the HTML. How are the SVG icons getting in there on the mobile menu? Are you modifying the twig templates?

Can you screenshot the menu item form page for the Services menu item?

aanjaneyam’s picture

StatusFileSize
new54.69 KB
new63.41 KB
new53.02 KB

I have attached the requested screenshot in 3 parts as somehow i was unable to take the whole page at once.

tanc’s picture

Assigned: Unassigned » tanc

I've now been able to replicate your issue. It looks like using <nolink> as the value for the field labelled Link when adding a menu link item through the UI results in a broken mmenu. This is confirmed by looking at the page source before JavaScript is applied:

<ul class="clearfix nav navbar-nav">
  <li class="menu-item--_05e9416-aac7-4076-b477-78bc4d786ec1 nav-item">
    <a href="/" class="nav-link" data-drupal-link-system-path="&lt;front&gt;">Home</a>
  </li>
  <li class="menu-item--_78d1d01-9ff2-4e3a-8692-9b1d240d93c9 nav-item menu-item--expanded dropdown">
    <span class="nav-link dropdown-toggle" data-toggle="dropdown" aria-expanded="false" aria-haspopup="true">About Varbase</span>
    <ul class="dropdown-menu">
      <li class="menu-item--_21bc099-1b96-471b-9ee3-c9ab3ae378f6 dropdown-item">
        <a href="http://google.com">A sub item</a>
      </li>
    </ul>
  </li>
  <li class="menu-item--b446aefb-7b73-40af-9f03-5e466dacc4f9 nav-item">
    <a href="/form/contact" class="nav-link" data-drupal-link-system-path="webform/contact">Contact Us</a>
  </li>
</ul>

Compared with the HTML produced by mmenu when it parses the above:

<ul class="clearfix navbar-nav mm-listview">
  <li class="menu-item--_05e9416-aac7-4076-b477-78bc4d786ec1 mm-listitem">
    <a href="/" class="mm-listitem__text is-active" data-drupal-link-system-path="<front>">Home</a>
  </li>
  <li class="menu-item--_78d1d01-9ff2-4e3a-8692-9b1d240d93c9 menu-item--expanded dropdown mm-listitem">
    <a class="mm-btn mm-btn_next mm-listitem__btn mm-listitem__text" href="#mm-2">About Varbase<span class="mm-sronly">Open submenu</span></a>
  </li>
  <li class="menu-item--b446aefb-7b73-40af-9f03-5e466dacc4f9 mm-listitem">
    <a href="/form/contact" class="mm-listitem__text" data-drupal-link-system-path="webform/contact">Contact Us</a>
  </li>
</ul>

The next step is to determine whether the incompatibility is due to varbase/bootstrap templates or whether it exists on a default Drupal install.

tanc’s picture

In fact the problem is worse, adding any menu item with children results in a broken mmenu. I'm pretty sure the templates the bootstrap barrio theme are applying are causing the issue.

tanc’s picture

Title: Children of a menu item do not appear in the offcanvas mobile menu » Varbase incompatibility: Children of a menu item do not appear in the offcanvas mobile menu

The problematic template being used for the main menu is themes/contrib/vartheme_bs4/templates/menu/menu--main.html.twig. This is applying to all versions of the main menu including the off-canvas one.

The problem is that there are no template suggestions or templates added for the off-canvas menu. In some ways it would be sensible for this module to provide a stock template for the off canvas menu based on Drupal's stable template with a higher specificity so that vartheme_bs4 doesn't take over and break things. This could then be overridden by the developer in their theme should they need to.

I will look at doing this tomorrow. Thanks for the bug report!

tanc’s picture

Version: 4.3.1 » 4.3.x-dev
StatusFileSize
new0 bytes

Here is an initial patch to test. I'd like to write some tests to confirm that this fixes the problem before committing but it would be good to get your feedback on whether it works for you first.

tanc’s picture

StatusFileSize
new2.91 KB

Apologies, previous patch was empty... this one should work

tanc’s picture

Status: Active » Needs review
Issue tags: +Needs tests
aanjaneyam’s picture

@tanc sorry I will come back to you in couple of days as I am away and unfortunately have falen ill.

tanc’s picture

No problem, take your time. I hope you feel better soon!

jdflorez’s picture

I had the same issue with a different theme due to the `main-menu.twig.html` included in the base theme. After applying the patch #12 I can see the 3rd level menu items rendering in the off canvas menu. I'm using version 4.3.1

aanjaneyam’s picture

@tanc. I can confirm that after applying the patch I can see the children of the main "Services" menu item and tap/click on them to reach the desired page. However, I can still see the font awesome SVG icons meant for the horizontal menu (left arrows) in the children and children of children of Services menu. The down arrow earlier appearing in the main Services icon has now disappeared.

aanjaneyam’s picture

StatusFileSize
new10.99 KB

I have attached a screenshot for the svg icons on children.

tanc’s picture

Status: Needs review » Reviewed & tested by the community

@aanjaneyam I hate to do this to you but the fontawesome problem you're having should really be a separate issue so that we can keep this one related to the varbase/bootstrap theme incompatibility. Can you open a new issue and detail the reproduction steps, including what module/method you're using to inject the fontawesome icons?

I'm marking this issue as RTBC as the patch has been confirmed to work by yourself and others.

aanjaneyam’s picture

@tanc. I mentioned the arrow/svg issue as it was discussed before in this issue above. I haven't added anything. It was a question put to me.

aanjaneyam’s picture

And the steps to replicate are in the screenshots for Services menu item page above. It is also shown in the screenshot for off-canvas menu above. However, if you think it is not related to the twig/HTML template dealt in this issue then I will create a new issue.

tanc’s picture

Yes please, can you create a new issue? The reason is this one is focused on fixing a particular issue (the children not appearing in off canvas menu) and it is resolved so we can commit the fix and close this issue. It is always better to have focused issues on one particular problem at a time.

tanc’s picture

Version: 4.3.x-dev » 4.4.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs tests

This was committed to the 4.4.x branch but for some reason the commit isn't showing up here.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.