Problem/Motivation
When configuring a onepage website with sections discriminated by IDs, you will have a main menu which item links are of type:
<front>#anchor
In this case, a click on the menu will navigate on the same page, thus not trigger a page refresh. Doing so, the superfish menu won't close. In mobile navigation, that feels odd because user does not notice he actually moved to the desired link.
Steps to reproduce
- Install a fresh Drupal 8
- Install and activate the superfish menu and it's library
- Configure le main menu for instance to actually use superfish
- Add in your menu multiple links (eventually hierarchically to test also submenus) with links like
<front>#anchor. That wil give you a onepage website, with the menu linking to your content sections - Use the superfish menu as a user would, including in smallscreen : you will navigate to your various page section, but the menu won't close as you do.
Proposed resolution
Add a 'click' listener on menu items to actually close the menu if items are not submenu open/close placeholders (what is called 'button' is code)
Remaining tasks
Because the code actually belong here: https://github.com/mehrpadin/Superfish-for-Drupal
I made a pull request there. But the issue is opened here to let users find it more easily.
make the code changeprovide pull request: https://github.com/mehrpadin/Superfish-for-Drupal/pull/30- review the code
- merge and release
API changes
No API change breaks
But it will probably add a function to close the menu, I wonder if exposing publicly that function would also let users that want to close the superfish when click anywhere on page could use it.
Comments
Comment #2
dom. commentedPull request as been created for this: https://github.com/mehrpadin/Superfish-for-Drupal/pull/30
Comment #3
dimitri1972 commentedThe new code to fix this problem works fine for me. Thx
Comment #4
adnaj_bukaj commented#2 did not work for me.
Ended up with simple custom script loaded with theme.
When user clicks on link, class "sf-expanded" is removed and class "sf-hidden" is added.
Hope this will help someone. I´m ready to hear better solution!
_________________________________________________________
_________________________________________________________
Comment #6
lobsterr commentedI found other way to handle it. it is available in a new release of library https://github.com/LOBsTerr/drupal-superfish/releases/tag/2.3.10
Thank you for your contribution