Shopify themes, liquid, logos, and UX
Hi! My mega-menu will not stay open when I go to click on a lower level menu item once I remove my cursor from the menu item itself. This is my website. Can you please tell me how I can fix this? I am using Trade theme.
Any way to also fit it to drop down under the menu item and only open as wide as the actual mega-menu contents? Like how this one does on another site
Thank you!
This could be done using the custom liquid code and css.
You can Hire a shopify developer for this.
If need any help from my end Please let me know, Contact info is in signature.
With Regards,
Laddi
@jordanbford1,
I am from Mageplaza - Shopify solution expert.
To solve your issue, you need to modify your JavaScript logic. Here are the steps you can follow to update the Javascript:
1. Access Your Theme Files:
2. Edit the JavaScript File:
const inlineMenu = document.querySelector(".header__inline-menu");
if (inlineMenu) {
const detailsItems = inlineMenu.querySelectorAll("details");
detailsItems.forEach(item => {
const ulElement = item.querySelector("ul");
// Ensure ulElement exists
if (!ulElement) return;
const currentMenuIndex = item.getAttribute('id')?.split('-')[2];
if (!currentMenuIndex) return;
const menuContentId = `MegaMenu-Content-${currentMenuIndex}`;
const menuContent = document.getElementById(menuContentId);
// Ensure the menu content exists
if (!menuContent) return;
item.addEventListener("mouseover", () => {
item.setAttribute("open", true);
// Remove redundant listeners
const closeMenu = () => {
item.removeAttribute("open");
};
ulElement.addEventListener("mouseleave", closeMenu, { once: true });
menuContent.addEventListener("mouseleave", closeMenu, { once: true });
});
});
}
Please let me know if it is functioning as expected.
Best regards.
Mageplaza | Top-Rated Shopify Agency | Trusted by 230,000+ worldwide merchants
If our suggestion works for you, please give it a Like or mark it as a Solution!
Should you have any questions or concerns, feel free to contact us via consultant@mageplaza.com
@mageplaza-cs I am having trouble locating which file controls this mega-menu. Any idea the name of it?
hi @jordanbford1,
You can locate the file that controls the mega menu in the Assets folder, which contains all the JavaScript files for your website. The structure and file names may vary between themes, so I cannot provide the exact file name.
Mageplaza | Top-Rated Shopify Agency | Trusted by 230,000+ worldwide merchants
If our suggestion works for you, please give it a Like or mark it as a Solution!
Should you have any questions or concerns, feel free to contact us via consultant@mageplaza.com
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024