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:
parent
19a0a5b64f
commit
35ae0bc5a4
|
@ -5253,7 +5253,6 @@
|
||||||
this.collection.on( 'reset', this.render, this );
|
this.collection.on( 'reset', this.render, this );
|
||||||
|
|
||||||
this.listenTo( this.controller, 'library:selection:add', this.attachmentFocus );
|
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.
|
// Throttle the scroll handler and bind this.
|
||||||
this.scroll = _.chain( this.scroll ).bind( this ).throttle( this.options.refreshSensitivity ).value();
|
this.scroll = _.chain( this.scroll ).bind( this ).throttle( this.options.refreshSensitivity ).value();
|
||||||
|
@ -5281,10 +5280,14 @@
|
||||||
|
|
||||||
arrowEvent: function( event ) {
|
arrowEvent: function( event ) {
|
||||||
var attachments = this.$el.children( 'li' ),
|
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(),
|
index = attachments.filter( ':focus' ).index(),
|
||||||
row = ( index + 1 ) <= perRow ? 1 : Math.ceil( ( index + 1 ) / perRow );
|
row = ( index + 1 ) <= perRow ? 1 : Math.ceil( ( index + 1 ) / perRow );
|
||||||
|
|
||||||
|
if ( index === -1 ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Left arrow
|
// Left arrow
|
||||||
if ( 37 === event.keyCode ) {
|
if ( 37 === event.keyCode ) {
|
||||||
if ( 0 === index ) {
|
if ( 0 === index ) {
|
||||||
|
@ -6001,6 +6004,9 @@
|
||||||
AttachmentView: this.options.AttachmentView
|
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 );
|
this.views.add( this.attachments );
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue