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. Props Giorgio25b, suzylah, yuhin, samful, bdcstr. Fixes #48916. Built from https://develop.svn.wordpress.org/trunk@47784 git-svn-id: http://core.svn.wordpress.org/trunk@47560 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2517abb4bd
commit
2eef7ee2ac
|
@ -137,6 +137,17 @@ twentytwenty.coverModals = {
|
||||||
var target = event.target;
|
var target = event.target;
|
||||||
var modal = document.querySelector( '.cover-modal.active' );
|
var modal = document.querySelector( '.cover-modal.active' );
|
||||||
|
|
||||||
|
// if target onclick is <a> 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 ) {
|
if ( target === modal ) {
|
||||||
this.untoggleModal( target );
|
this.untoggleModal( target );
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.5-alpha-47783';
|
$wp_version = '5.5-alpha-47784';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue