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. Built from https://develop.svn.wordpress.org/trunk@29582 git-svn-id: http://core.svn.wordpress.org/trunk@29356 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
49937c88f9
commit
8a545bf05e
|
@ -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 );
|
||||
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue