Solved Templates

SubMenu not Appear in Mobile View

Asked by MCPO-UMP 1 year ago Last activity 1 year ago

Hi, submenu not appear in mobile view. After update to Joomla4.

PHP Version 7.4.33
Joomla 4.4.10

https://prnt.sc/iPJfjoAhQvS5

Accepted answer

Marked as the solution
Ziaul Kabir Staff

I add this js and css in your custom code section, Follow this guide to add custom code: https://www.joomshaper.com/documentation/helix-framework/custom-code-css-js-meta

document.addEventListener("DOMContentLoaded", function () {
  document.querySelectorAll(".menu-parent").forEach(function (parent) {
    // Create a span element for the toggle
    let toggle = document.createElement("span");
    toggle.classList.add("submenu-toggle");
    toggle.textContent = "+"; // Default to collapsed

    // Insert toggle icon inside the menu parent
    parent.querySelector("a").after(toggle);

    // Toggle submenu on click
    toggle.addEventListener("click", function () {
      let submenu = parent.querySelector(".menu-child");
      if (submenu) {
        submenu.style.display = submenu.style.display === "block" ? "none" : "block";
        toggle.textContent = submenu.style.display === "block" ? "−" : "+";
      }
    });
  });
});

anfd this css:

.menu-parent {
  position: relative;
}

.submenu-toggle {
  position: absolute !important;
  right: 10px;
  cursor: pointer;
  font-size: 18px !important;
  font-weight: bold;
    z-index: 12;
}

.menu-child {
  display: none; /* Initially hidden */
}

.menu-child.show {
  display: block;
}

.offcanvas-menu .offcanvas-inner .sp-module ul>li a, .offcanvas-menu .offcanvas-inner .sp-module ul>li span {
    display: flex;
    font-size: 1rem;
    padding: 0.125rem 0;
    position: unset;
}
.offcanvas-menu .offcanvas-inner .sp-module ul>li {
    overflow: unset !important;
}

3 more replies

Ziaul Kabir Staff

Hello,

Thanks for reaching out to us. I apologize for the inconvenience. I have resolved your issue.

Please check and let me know if everything is working fine.

Thanks,

MCPO-UMP Asked this

Thank you for your prompt assistance. Could you share the solution to this issue? There are still nearly 40 websites that need fixing, so I would like to correct them myself.

Log in to reply.