Published
November 17, 2022
Updated
If you have a section anchor link inside of a dropdown menu, then when you click it the browser scrolls the page without closing the menu first.
This seems to happen most often when the menu is set to open on hover.
Add this small piece of script in the </body> custom code of your site to remedy this.
How it works;
- Detects clicks specifically on anchor links, since the href="#...
- Finds its parent nav element and removes w--open class
- Finds its parent dropdown toggle and removes the w--open class
Tested;
- chrome windows
- chrome mobile
References
https://discourse.webflow.com/t/close-dropdown-menu/74499
https://discourse.webflow.com/t/ability-to-close-dropdown-menu-after-link-is-clicked/5581/24
FAQs
Answers to frequently asked questions.