Customizer: Avoid losing focus when adding widgets via keyboard.

props sathishn.
fixes #28835.
Built from https://develop.svn.wordpress.org/trunk@29237


git-svn-id: http://core.svn.wordpress.org/trunk@29021 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-07-19 01:19:14 +00:00
parent 1d637d85e0
commit 53d2839324
2 changed files with 10 additions and 2 deletions

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();
}
}
});

File diff suppressed because one or more lines are too long