From 19a34bb49ca956d93cd9992014fb944bda8cf9e2 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 20 Aug 2014 19:59:59 +0000 Subject: [PATCH] Cleanup after [29220]: `media.controller.Library` is State/Backbone Model and should not touch views. See #23560. git-svn-id: https://develop.svn.wordpress.org/trunk@29558 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-views.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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() ),