Administration: Close admin menu when focus moves to body.
User should not have to reach the admin menu toggle in order to close the menu. This can be a problem for one-handed mobile use, users with small hands, and numerous other situational usages. Close the admin menu when focus moves anywhere other than the menu or the menu toggle and the current document is active. Props kaneva, sabernhardt, costdev, ryokuhi, hellofromtonya, dhusakovic, thelovekesh, joedolson. Fixes #53587. Built from https://develop.svn.wordpress.org/trunk@55326 git-svn-id: http://core.svn.wordpress.org/trunk@54859 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5584cf60c0
commit
cc27b6cc19
|
@ -1702,6 +1702,25 @@ $( function() {
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
// Close sidebar when focus moves outside of toggle and sidebar.
|
||||||
|
$( '#wp-admin-bar-menu-toggle, #adminmenumain' ).on( 'focusout', function( e ) {
|
||||||
|
var focusIsInToggle, focusIsInSidebar;
|
||||||
|
|
||||||
|
if ( ! $wpwrap.hasClass( 'wp-responsive-open' ) || ! document.hasFocus() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// A brief delay is required to allow focus to switch to another element.
|
||||||
|
setTimeout( function() {
|
||||||
|
focusIsInToggle = $.contains( $( '#wp-admin-bar-menu-toggle' )[0], $( ':focus' )[0] );
|
||||||
|
focusIsInSidebar = $.contains( $( '#adminmenumain' )[0], $( ':focus' )[0] );
|
||||||
|
|
||||||
|
if ( ! focusIsInToggle && ! focusIsInSidebar ) {
|
||||||
|
$( '#wp-admin-bar-menu-toggle' ).trigger( 'click.wp-responsive' );
|
||||||
|
}
|
||||||
|
}, 10 );
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
// Add menu events.
|
// Add menu events.
|
||||||
$adminmenu.on( 'click.wp-responsive', 'li.wp-has-submenu > a', function( event ) {
|
$adminmenu.on( 'click.wp-responsive', 'li.wp-has-submenu > a', function( event ) {
|
||||||
if ( ! $adminmenu.data('wp-responsive') ) {
|
if ( ! $adminmenu.data('wp-responsive') ) {
|
||||||
|
@ -1709,6 +1728,7 @@ $( function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$( this ).parent( 'li' ).toggleClass( 'selected' );
|
$( this ).parent( 'li' ).toggleClass( 'selected' );
|
||||||
|
$( this ).trigger( 'focus' );
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.2-beta1-55325';
|
$wp_version = '6.2-beta1-55326';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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