Skip to content

Commit 2e7343c

Browse files
committed
Customizer: Handle keyboard focus after adding site icon or logo.
Fix focus loss after assigning a site icon or a site logo in the customizer. Sets focus to the 'Remove' button immediately following the setting control. Props joedolson, rishabhwp, krupajnanda, pmbaldha. Fixes #63832. git-svn-id: https://develop.svn.wordpress.org/trunk@60785 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 9a2136f commit 2e7343c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/js/_enqueues/wp/customize/controls.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4726,10 +4726,19 @@
47264726
* @param {Object} attachment
47274727
*/
47284728
setImageFromAttachment: function( attachment ) {
4729+
var control = this;
47294730
this.params.attachment = attachment;
47304731

47314732
// Set the Customizer setting; the callback takes care of rendering.
47324733
this.setting( attachment.id );
4734+
4735+
// Set focus to the first relevant button after the icon.
4736+
_.defer( function() {
4737+
var firstButton = control.container.find( '.actions .button' ).first();
4738+
if ( firstButton.length ) {
4739+
firstButton.focus();
4740+
}
4741+
} );
47334742
}
47344743
});
47354744

@@ -4812,7 +4821,8 @@
48124821
* @param {Object} attachment
48134822
*/
48144823
setImageFromAttachment: function( attachment ) {
4815-
var sizes = [ 'site_icon-32', 'thumbnail', 'full' ], link,
4824+
var control = this,
4825+
sizes = [ 'site_icon-32', 'thumbnail', 'full' ], link,
48164826
icon;
48174827

48184828
_.each( sizes, function( size ) {
@@ -4833,6 +4843,14 @@
48334843
// Update the icon in-browser.
48344844
link = $( 'link[rel="icon"][sizes="32x32"]' );
48354845
link.attr( 'href', icon.url );
4846+
4847+
// Set focus to the first relevant button after the icon.
4848+
_.defer( function() {
4849+
var firstButton = control.container.find( '.actions .button' ).first();
4850+
if ( firstButton.length ) {
4851+
firstButton.focus();
4852+
}
4853+
} );
48364854
},
48374855

48384856
/**

0 commit comments

Comments
 (0)