Customizer: Avoid losing focus when adding widgets via keyboard.

props sathishn.
fixes #28835.

git-svn-id: https://develop.svn.wordpress.org/trunk@29237 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2014-07-19 01:18:39 +00:00
parent bcff52c1b0
commit 7a01c6af7b

View File

@ -316,10 +316,13 @@
isEsc = ( event.which === 27 ),
isDown = ( event.which === 40 ),
isUp = ( event.which === 38 ),
isTab = ( event.which === 9 ),
isShift = ( event.shiftKey ),
selected = null,
firstVisible = this.$el.find( '> .widget-tpl:visible:first' ),
lastVisible = this.$el.find( '> .widget-tpl:visible:last' ),
isSearchFocused = $( event.target ).is( this.$search );
isSearchFocused = $( event.target ).is( this.$search ),
isLastWidgetFocused = $( event.target ).is( '.widget-tpl:visible:last' );
if ( isDown || isUp ) {
if ( isDown ) {
@ -357,6 +360,11 @@
} else if ( isEsc ) {
this.close( { returnFocus: true } );
}
if ( isTab && ( isShift && isSearchFocused || ! isShift && isLastWidgetFocused ) ) {
this.currentSidebarControl.container.find( '.add-new-widget' ).focus();
event.preventDefault();
}
}
});