This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Search experience on mobile

#29618
Ernest MarcinkoErnest Marcinko
Keymaster

This issue is not generic at all, not standard stock menus (in terms of the additional scripts and styling) – normally, menus does not do this for this exact reason (to prevent issues with other interactive events). Therefore there is no generic solution I can implement to prevent a behavior that should not happen in the first place. Fiddling with other code event handlers will cause more issues only. Programmers cannot think of everything. I am sure, that the menu coder had a good reason to code this behavior – however it prevents combining other interactive items to the menu – which is definitely not promised by them either.

We can try an approach to remove all of the touch and click handlers from the menu, and hope that it prevents the closing. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

add_action('wp_footer', 'asp_remove_menu_closing');
function asp_remove_menu_closing() {
	?>
	<script>
	jQuery(function($){
		$('li.menu-item, li.menu-item a').off('touchend').off('touchstart').off('click');
	});
	</script>
	<?php
}

There is a tiny chance that this may actually work, but may also cause some unexpected behavior, so make sure to test it.