From 38a83c11bd5602c71c68b0e01c961762bbb9b267 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta Date: Sat, 16 Aug 2025 10:05:30 +0530 Subject: [PATCH] fix: restore focus after setting site logo or icon in Customizer --- src/js/_enqueues/wp/customize/controls.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/js/_enqueues/wp/customize/controls.js b/src/js/_enqueues/wp/customize/controls.js index bc72f589c7203..5da6887b2f41f 100644 --- a/src/js/_enqueues/wp/customize/controls.js +++ b/src/js/_enqueues/wp/customize/controls.js @@ -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(); + } + } ); } }); @@ -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 ) { @@ -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(); + } + } ); }, /**