Dawn Theme - How to add the ability to hover over dropdown in navigation menu without clicking

Solved
Caligirl917
Excursionist
18 0 5

How do i make it so the menu drops down when I hover the mouse over it instead of only when I click it?

Accepted Solution (1)

Accepted Solutions
wmisback
Shopify Partner
26 3 20

This is an accepted solution.

Glad to help! Could you please mark it as an accepted solution?

Check out my Shopify coding tutorials on YouTube
Need custom coding done? Get in touch: willmiswebdev@gmail.com

View solution in original post

Replies 17 (17)
Kinjaldavra
Shopify Partner
2302 569 1405

hello @Caligirl917 

Please provide website url and if your store is password protected then also provide password So I will check and provide a solution here.

Want to theme customize contact us E-mail : natztech2312@gmail.com | Whatsapp
Build your professional store with GemPage Page Builder
dmwwebartisan
Shopify Partner
10710 2339 3325

@Caligirl917 

Please share your store URL!

Thanks!

If helpful then please Like and Accept Solution | Email: dmw.webartisan@gmail.com | Instagram: @dmw.webartisan
Check here PageFly App to customize your pages | Bag is a cart drawer that maximizes your sales. View app →
wmisback
Shopify Partner
26 3 20

Hi Sara, I just posted a video tutorial on my Youtube channel that may be what you are looking for.

Steps

1. Open your site's code editor

2. Open your site's header.liquid file (should be located in the sections folder

3. On around line 500 you will see a liquid tag referring to sticky headers, after this line copy the following code (it's a simple script that adds hover eventListeners to all menu items that create dropdowns)

<script>
  let items = document.querySelector(".header__inline-menu").querySelectorAll("details");
  console.log(items)
  items.forEach(item => {
    item.addEventListener("mouseover", () => {
      item.setAttribute("open", true);
      item.querySelector("ul").addEventListener("mouseleave", () => {
        item.removeAttribute("open");
      });
    item.addEventListener("mouseleave", () => {
      item.removeAttribute("open");
    });
  });
  
  });
</script>
Copy

 Hope this helps, let me know if you have any issues!

Check out my Shopify coding tutorials on YouTube
Need custom coding done? Get in touch: willmiswebdev@gmail.com
Caligirl917
Excursionist
18 0 5
wmisback
Shopify Partner
26 3 20

This is an accepted solution.

Glad to help! Could you please mark it as an accepted solution?

Check out my Shopify coding tutorials on YouTube
Need custom coding done? Get in touch: willmiswebdev@gmail.com
HighPointCoffee
New Member
1 0 0

Hello, 

Is there a way I can have the submenus and their options displayed all at once (preferably in separate columns) while hovering over the main parent menu? So you wouldn't have to hover over the submenus as well to see their options?

Thanks!

crypto_punk
Shopify Partner
1 0 1
DavidR2D2
Tourist
9 0 4

Question about editing the source code, when Shopify does updates, does it override the code that we insert and we have to do it all over again later, or does our code remain intact and unchanged? Thanks. 

PawelCraftline
New Member
1 0 1

@DavidR2D2

 

Just dropping by for the solution thought I'd answer your question.

 

No, Shopify does not change amended code upon update to my knowledge. This would make a lot of businesses extremely unhappy, as most professional Shopify stores have custom code to some capacity. Hope this helps.

AlessandroGn
New Member
16 0 0

This solution not work with Dawn 2.0

Magento developer, Shopify developer, Woocommerce Developer
made4Uo
Shopify Partner
1478 228 343

Try this one. No javascript being use. Just HTML and css. Check the video for more info

 

Just be reminded that we are volunteering to help.
✿✿✿-

Likes  

and

 Accept as Solution

  will be much appreciated.✌-✿✿✿
For more Shopify Solutions and custom codes, just visit

 Made4Uo's website

.
Keep your stuffs private. Refrain from giving unnecessary access to your store.
blaquephoenixcr
New Member
3 0 0

Thank you so much. I've been trying to find this for my Sense theme fore the longest while now. You are a lifesaver.

Maollin
New Member
6 0 0

Hi @wmisback , 

 

first of all thank you for the code as well as for your videos on YouTube. I tried it out and it worked perfectly for me, the only thing is, that I have two submenu points under my menu. Now with the help of your code I can hover over the menu items and also select my submenu pages but when I move my mouse away from the first item, the entire menu closes and I can't select my 2nd sub-item at all or move my mouse to the 2nd sub-item. Do you also have this problem or is there any known solution for something like this? 

 

I hope you can help me. 

 

Thank you in advance

 

Maollin

shashavali
New Member
1 0 0
glowtheunicorn
New Member
1 0 0
Deadmorgan
New Member
2 0 0

In the new 5.0 this opens the megamenu, but when you try to move the mouse down to the menu it closes. Any idea?