Auto closing menus dropdown on one navigation page

Hi, I am using pro theme and have set up one page navigation with different headers on different devices. Now, is there a way to autoclose dropdown menu item when tapped on mobile device (since it points to anchor and stays open by default since the page isn’t reloading)?
Many thanks for any help, DK

Hi There,

Thank you for writing in, this is actually on our issue tracker and it has been marked as fixed. Please stay tune for the next release. Sorry we can not provide an exact date of the next release though.

Cheers!

ok, thank you, that is very nice to hear… cheers

You’re welcome!

Hi. Is there any interim fix you can suggest for this while we wait for the next release?

Hi @dsmillie,

You can try adding this custom CSS under Pro > Theme Options > CSS:

jQuery(function($) {
	$('.x-menu li.menu-item a.x-anchor').on('click touchend', function(event) {
		var button = $(".x-off-canvas-close");
		if( button.length > 0 ){
			button.trigger('click');
		}
	});
});

Hope it helps :slight_smile:

Thanks @thai. Unfortunately, it didn’t seem to have any effect. The dropdown menu still stays open when clicking on a link until you manually close it.

Hi again,

Please replace the previous code with the following code:

jQuery(document).ready(function($){
	$('.x-menu.x-menu-dropdown .x-anchor').on("click touchend", function(event) {
		if ($(event.target).attr('class') != "x-anchor-sub-indicator") {
			$('.x-anchor-toggle').click();
		}
	});
});

Don’t forget to clear your browser’s cache after adding the code. Let us know how this goes!

It works perfectly! Thank you so much.

you are most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.