diff --git a/wp-admin/js/customize-controls.js b/wp-admin/js/customize-controls.js index d44aac55ad..96f776744f 100644 --- a/wp-admin/js/customize-controls.js +++ b/wp-admin/js/customize-controls.js @@ -881,9 +881,8 @@ $('.back').keydown( function( event ) { if ( 9 === event.which ) // tab return; - var thisHref = $(this).attr('href'); if ( 13 === event.which ) // enter - window.location = thisHref; + parent.send( 'close' ); event.preventDefault(); }); diff --git a/wp-includes/js/customize-loader.js b/wp-includes/js/customize-loader.js index bd34484465..2ecbbe0fbf 100644 --- a/wp-includes/js/customize-loader.js +++ b/wp-includes/js/customize-loader.js @@ -28,8 +28,10 @@ window.wp = window.wp || {}; $('#wpbody').on( 'click', '.load-customize', function( event ) { event.preventDefault(); + // Store a reference to the link that opened the customizer. + Loader.link = $(this); // Load the theme. - Loader.open( $(this).attr('href') ); + Loader.open( Loader.link.attr('href') ); }); // Add navigation listeners. @@ -123,6 +125,10 @@ window.wp = window.wp || {}; this.active = false; this.trigger( 'close' ); + + // Return focus to link that was originally clicked. + if ( this.link ) + this.link.focus(); }, closed: function() {