Make WordPress Core

Changeset 60785


Ignore:
Timestamp:
09/19/2025 07:55:26 PM (14 months ago)
Author:
joedolson
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/customize/controls.js

    r60715 r60785  
    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        });
    … …  
    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
    … …  
    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
Note: See TracChangeset for help on using the changeset viewer.