From 506bf18b7e72229e91ac9f4e80f27831f1dca366 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 24 Aug 2014 16:42:14 +0000 Subject: [PATCH] Media Grid: restore focus to the selected item when shift-tab away from the attachment details sidebar. Fixes #29303. git-svn-id: https://develop.svn.wordpress.org/trunk@29584 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-views.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index c1ad5a99cb..19bfd32d59 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -5278,6 +5278,10 @@ this.$( 'li:first' ).focus(); }, + restoreFocus: function() { + this.$( 'li.selected:first' ).focus(); + }, + arrowEvent: function( event ) { var attachments = this.$el.children( 'li' ), perRow = this.$el.data( 'columns' ), @@ -6005,7 +6009,8 @@ }); // Add keydown listener to the instance of the Attachments view - this.attachments.listenTo( this.controller, 'attachment:keydown:arrow', this.attachments.arrowEvent ); + this.attachments.listenTo( this.controller, 'attachment:keydown:arrow', this.attachments.arrowEvent ); + this.attachments.listenTo( this.controller, 'attachment:details:shift-tab', this.attachments.restoreFocus ); this.views.add( this.attachments ); @@ -6582,7 +6587,7 @@ */ toggleSelectionHandler: function( event ) { if ( 'keydown' === event.type && 9 === event.keyCode && event.shiftKey && event.target === this.$( ':tabbable' ).get( 0 ) ) { - this.$( ':tabbable' ).eq( 0 ).blur(); + this.controller.trigger( 'attachment:details:shift-tab', event ); return false; }