From a08cd8ecede1a79a496814220eead71e442c2939 Mon Sep 17 00:00:00 2001 From: Sukhendu Sekhar Guria Date: Tue, 27 Oct 2026 14:44:33 +0530 Subject: [PATCH] Twenty Twelve: Fix sub-menu access on touch devices --- src/wp-content/themes/twentytwelve/functions.php | 2 +- src/wp-content/themes/twentytwelve/js/navigation.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wp-content/themes/twentytwelve/functions.php b/src/wp-content/themes/twentytwelve/functions.php index 65e93c3387886..d40813b3345bb 100644 --- a/src/wp-content/themes/twentytwelve/functions.php +++ b/src/wp-content/themes/twentytwelve/functions.php @@ -202,7 +202,7 @@ function twentytwelve_scripts_styles() { 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'jquery' ), - '20250303', + '20261027', array( 'in_footer' => false, // Because involves header. 'strategy' => 'defer', diff --git a/src/wp-content/themes/twentytwelve/js/navigation.js b/src/wp-content/themes/twentytwelve/js/navigation.js index 93bc0d3f03484..27baa6833bcc7 100644 --- a/src/wp-content/themes/twentytwelve/js/navigation.js +++ b/src/wp-content/themes/twentytwelve/js/navigation.js @@ -52,10 +52,11 @@ } ); if ( 'ontouchstart' in window ) { - $('body').on( 'touchstart.twentytwelve', '.menu-item-has-children > a, .page_item_has_children > a', function( e ) { + $( '.main-navigation' ).on( 'touchstart.twentytwelve', '.menu-item-has-children > a, .page_item_has_children > a', function( e ) { var el = $( this ).parent( 'li' ); - if ( ! el.hasClass( 'focus' ) ) { + // Sub-menus are only hidden behind hover on large screens. + if ( ! el.hasClass( 'focus' ) && window.matchMedia( '(min-width: 600px)' ).matches ) { e.preventDefault(); el.toggleClass( 'focus' ); el.siblings( '.focus').removeClass( 'focus' );