From 190350ecea25d958ad2176071c34b6239729e9de Mon Sep 17 00:00:00 2001 From: audrasjb Date: Tue, 24 Jan 2023 12:59:10 +0000 Subject: [PATCH] Twenty Twenty-One: Refine `primary-navigation.js` behavior for anchor links. This changeset fixes a bug where clicking on an anchor link in the content changes the state of the button that opens and closes the responsive menu. It adds a conditional to check if the clicked anchor link is inside the primary navigation menu (`#site-navigation`), in order to prevent content anchor links from changing the state of the button. Known limitations: The state of the button is not reset when the browser is resized. If a menu anchor link is first clicked while on desktop width, and the browser width is reduced, the menu button will show the text "Close" even though the menu is not opened. Props andreaboe, sabernhardt, poena, afercia, chaion07, cu121, mukesh27. Fixes #53331. Built from https://develop.svn.wordpress.org/trunk@55124 git-svn-id: http://core.svn.wordpress.org/trunk@54657 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../themes/twentytwentyone/assets/js/primary-navigation.js | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-content/themes/twentytwentyone/assets/js/primary-navigation.js b/wp-content/themes/twentytwentyone/assets/js/primary-navigation.js index ec15e106dc..c53af8268c 100644 --- a/wp-content/themes/twentytwentyone/assets/js/primary-navigation.js +++ b/wp-content/themes/twentytwentyone/assets/js/primary-navigation.js @@ -172,9 +172,9 @@ function twentytwentyoneExpandSubMenu( el ) { // jshint ignore:line * * @since Twenty Twenty-One 1.1 */ - document.addEventListener( 'click', function( event ) { + document.getElementById( 'site-navigation' ).addEventListener( 'click', function( event ) { // If target onclick is with # within the href attribute - if ( event.target.hash && event.target.hash.includes( '#' ) ) { + if ( event.target.hash ) { wrapper.classList.remove( id + '-navigation-open', 'lock-scrolling' ); twentytwentyoneToggleAriaExpanded( mobileButton ); // Wait 550 and scroll to the anchor. diff --git a/wp-includes/version.php b/wp-includes/version.php index 163ea92565..67c9a7b03d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55123'; +$wp_version = '6.2-alpha-55124'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.