Shopify themes, liquid, logos, and UX
Hey all. I have what I'm hoping is a simple issue to resolve. We're currently using a mega menu but are getting feedback from users that the mouseover menu expansion is detracting from the overall browsing experience.
I'd like help changing this behavior to a click vs. mouseover action, which fills the entire page unexpectedly.
Regards!
Matt
Solved! Go to the solution
This is an accepted solution.
Hi @Beenenm,
You can try this code by following these steps:
Step 1: Go to Online Store->Theme->Edit code.
Step 2: Search file theme.liquid
Step 3: Paste the below code at bottom of the file -> Save
<style>
.is-focused>.site-nav__dropdown{
visibility: hidden !important;
}
.is-activeLink>.site-nav__dropdown{
visibility: visible !important;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
window.addEventListener('DOMContentLoaded',(event)=>{
$('.site-nav--has-dropdown').each((_,item)=>{
$(item).on('click',(e)=>{
e.preventDefault()
$('.site-nav--has-dropdown').each((_,i)=>i.removeClass('is-activeLink'))
$(item).addClass('is-activeLink')
})
})
});
</script>
Hope my solution works perfectly for you!
Best regards,
Victor | PageFly
This is an accepted solution.
Hi @Beenenm,
You can try this code by following these steps:
Step 1: Go to Online Store->Theme->Edit code.
Step 2: Search file theme.liquid
Step 3: Paste the below code at bottom of the file -> Save
<style>
.is-focused>.site-nav__dropdown{
visibility: hidden !important;
}
.is-activeLink>.site-nav__dropdown{
visibility: visible !important;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
window.addEventListener('DOMContentLoaded',(event)=>{
$('.site-nav--has-dropdown').each((_,item)=>{
$(item).on('click',(e)=>{
e.preventDefault()
$('.site-nav--has-dropdown').each((_,i)=>i.removeClass('is-activeLink'))
$(item).addClass('is-activeLink')
})
})
});
</script>
Hope my solution works perfectly for you!
Best regards,
Victor | PageFly
That helped - thank you!
Hey Victor,
Your solution does make the menu work on click, but the items in the menu won't open when clicked now.
What I mean is that I can now click on the main menu element to display the sub-menu, but the elements in the sub-menu are not clickable.
Do I need to change something?
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024