Troubleshoot Webflow
Webflow mobile menu stays open after tapping a link
On a phone the mobile menu does not always close when a link is clicked on. Whether or not the menu closes depends on the link address.
Possible issues
- Menu fails to close when a section link is clicked.
- The page can be scrolled while the menu is open.
- Whilst the menu will close when a cross-page link is clicked, it fails to do so when a section link is clicked.
Check these in order
Investigate in this order. Usually an issue will be identified within the first couple of steps.
- 1
Understand the default functionality
The menu toggle is visible on tablet and smaller devices. Menu toggling occurs on a click.
- 2
Review the section link
Selecting the ‘Page section’ option in the Link settings causes a link to a section of the current page to be created. An address such as /#contact or a complete address finishing with #contact are different. Webflow’s documentation has no information about when a menu closes on a link click. However, analysis of the published code for the navbar reveals that, if a menu link address begins with a #, then clicking on it will cause the menu to close – but only if it was previously open. Cross-page links cause the browser to refresh the page and so there is no opportunity for a menu to close. My understanding of this came from analysing the published code rather than from Webflow’s documentation. Carry out your own testing on your website.
- 3
Adjust the link
Either select the ‘Page section’ option or type #contact into the URL box. Then, re-publish.
- 4
Be aware of the implications of common shared navigation bars
Many websites include a /#contact link in their navigation bar component so that it can be used from all pages. On the home page, this simply causes scrolling (without page-refreshing) and as the address does not begin with a #, the menu remains open. Although #contact will function on the home page, it causes problems on pages which do not contain a contact section. Either apply #contact only to those pages which do contain a contact section or insert a brief piece of custom code so that the menu closes when a menu link with a # in its address is clicked.
- 5
Recognise that the menu also closes on external clicks
Again, this is achieved via the same script.
- 6
Consider page switching
If bespoke code is preventing pages from refreshing when switching between them then there is no need for the menu to close since this only occurs on a # link or external click.
- 7
Avoid conflicting actions
Whilst the functionality for opening and closing a navigation bar is distinct from that for actions, traditional action functionality includes navigation bar controls – whereas the GSAP version does not. There is potential for a conflict between a manually coded open/close action for a navigation bar, and the default functionality.
- 8
Test your published website on a phone
Although the preview replicates the live website, it is always best to test on a genuine phone to observe real touch functionality.
Continue with the next task
Choose the page that will assist you with your next decision.
- Compare the two interaction systemsInteractions with GSAP and Classic, and how to keep animation accessible.Open
- Fix a page that won’t scroll on a phoneSticky sections, overflow and full-height sections.Open
- Check where custom code can goThe places code can be added and what each does to loading.Open