Skip to content

fix: restore focus after setting site logo or icon in Customizer #9499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/js/_enqueues/wp/customize/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4718,10 +4718,19 @@
* @param {Object} attachment
*/
setImageFromAttachment: function( attachment ) {
var control = this;
this.params.attachment = attachment;

// Set the Customizer setting; the callback takes care of rendering.
this.setting( attachment.id );

// Set focus to the first relevant button after the icon.
_.defer( function() {
var firstButton = control.container.find( '.actions .button' ).first();
if ( firstButton.length ) {
firstButton.focus();
}
} );
}
});

Expand Down Expand Up @@ -4804,7 +4813,8 @@
* @param {Object} attachment
*/
setImageFromAttachment: function( attachment ) {
var sizes = [ 'site_icon-32', 'thumbnail', 'full' ], link,
var control = this,
sizes = [ 'site_icon-32', 'thumbnail', 'full' ], link,
icon;

_.each( sizes, function( size ) {
Expand All @@ -4825,6 +4835,14 @@
// Update the icon in-browser.
link = $( 'link[rel="icon"][sizes="32x32"]' );
link.attr( 'href', icon.url );

// Set focus to the first relevant button after the icon.
_.defer( function() {
var firstButton = control.container.find( '.actions .button' ).first();
if ( firstButton.length ) {
firstButton.focus();
}
} );
},

/**
Expand Down
Loading