From 8e5980a77086dca1945003b9c205fcb1275b5487 Mon Sep 17 00:00:00 2001 From: whyisjake Date: Tue, 19 May 2020 22:50:07 +0000 Subject: [PATCH] Bundled Themes: Twenty Twenty anchor links don't work in mobile menu. Modifies the mobile modal menu javascript, so that anchor links will close the modal and scroll to the anchor within the page. This brings the changes from [47784] to the 5.4 branch. Props Giorgio25b, suzylah, yuhin, samful, bdcstr. Fixes #48916. Built from https://develop.svn.wordpress.org/branches/5.4@47829 git-svn-id: http://core.svn.wordpress.org/branches/5.4@47605 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/twentytwenty/assets/js/index.js | 11 +++++++++++ wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/wp-content/themes/twentytwenty/assets/js/index.js b/wp-content/themes/twentytwenty/assets/js/index.js index b6919261e8..c6f7a0a909 100644 --- a/wp-content/themes/twentytwenty/assets/js/index.js +++ b/wp-content/themes/twentytwenty/assets/js/index.js @@ -137,6 +137,17 @@ twentytwenty.coverModals = { var target = event.target; var modal = document.querySelector( '.cover-modal.active' ); + // if target onclick is with # within the href attribute + if ( event.target.tagName.toLowerCase() === 'a' && event.target.hash.includes( '#' ) && modal !== null ) { + // untoggle the modal + this.untoggleModal( modal ); + // wait 550 and scroll to the anchor + setTimeout( function() { + var anchor = document.getElementById( event.target.hash.slice( 1 ) ); + anchor.scrollIntoView(); + }, 550 ); + } + if ( target === modal ) { this.untoggleModal( target ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index c43d25d54f..1c8245ae3f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.4.2-alpha-47828'; +$wp_version = '5.4.2-alpha-47829'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.