Media: Only fire keyboard events for the Attachments view once.

Firing them twice was breaking arrow key navigation in media attachment grids.

props gcorne.
fixes #29304.


git-svn-id: https://develop.svn.wordpress.org/trunk@29582 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Helen Hou-Sandi 2014-08-24 16:17:01 +00:00
parent 19a0a5b64f
commit 35ae0bc5a4
1 changed files with 8 additions and 2 deletions

View File

@ -5253,7 +5253,6 @@
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.
this.scroll = _.chain( this.scroll ).bind( this ).throttle( this.options.refreshSensitivity ).value();
@ -5281,10 +5280,14 @@
arrowEvent: function( event ) {
var attachments = this.$el.children( 'li' ),
perRow = Math.round( this.$el.width() / attachments.first().outerWidth() ),
perRow = this.$el.data( 'columns' ),
index = attachments.filter( ':focus' ).index(),
row = ( index + 1 ) <= perRow ? 1 : Math.ceil( ( index + 1 ) / perRow );
if ( index === -1 ) {
return;
}
// Left arrow
if ( 37 === event.keyCode ) {
if ( 0 === index ) {
@ -6001,6 +6004,9 @@
AttachmentView: this.options.AttachmentView
});
// Add keydown listener to the instance of the Attachments view
this.attachments.listenTo( this.controller, 'attachment:keydown:arrow', this.attachments.arrowEvent );
this.views.add( this.attachments );