Make WordPress Core

Changeset 29237


Ignore:
Timestamp:
07/19/2014 01:18:39 AM (11 years ago)
Author:
SergeyBiryukov
Message:

Customizer: Avoid losing focus when adding widgets via keyboard.

props sathishn.
fixes #28835.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-widgets.js

    r29051 r29237  
    317317                isDown = ( event.which === 40 ),
    318318                isUp = ( event.which === 38 ),
     319                isTab = ( event.which === 9 ),
     320                isShift = ( event.shiftKey ),
    319321                selected = null,
    320322                firstVisible = this.$el.find( '> .widget-tpl:visible:first' ),
    321323                lastVisible = this.$el.find( '> .widget-tpl:visible:last' ),
    322                 isSearchFocused = $( event.target ).is( this.$search );
     324                isSearchFocused = $( event.target ).is( this.$search ),
     325                isLastWidgetFocused = $( event.target ).is( '.widget-tpl:visible:last' );
    323326
    324327            if ( isDown || isUp ) {
     
    357360            } else if ( isEsc ) {
    358361                this.close( { returnFocus: true } );
     362            }
     363
     364            if ( isTab && ( isShift && isSearchFocused || ! isShift && isLastWidgetFocused ) ) {
     365                this.currentSidebarControl.container.find( '.add-new-widget' ).focus();
     366                event.preventDefault();
    359367            }
    360368        }
Note: See TracChangeset for help on using the changeset viewer.