diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 76d6dc52ee..664575fffa 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -753,8 +753,7 @@ } this.get('selection').add( attachment ); - // Set focus back to where it goes when an attachment is selected. - $( '.attachments-browser .attachments .attachment' ).first().focus(); + this.frame.trigger( 'library:selection:add' ); }, /** @@ -5256,6 +5255,7 @@ this.collection.on( 'reset', this.render, this ); + this.listenTo( this.controller, 'library:selection:add', this.attachmentFocus ); this.listenTo( this.controller, 'attachment:keydown:arrow', this.arrowEvent ); // Throttle the scroll handler and bind this. @@ -5278,6 +5278,10 @@ _.defer( this.setColumns, this ); }, + attachmentFocus: function() { + this.$( 'li:first' ).focus(); + }, + arrowEvent: function( event ) { var attachments = this.$el.children( 'li' ), perRow = Math.round( this.$el.width() / attachments.first().outerWidth() ),