Make WordPress Core

Changeset 29582


Ignore:
Timestamp:
08/24/2014 04:17:01 PM (10 years ago)
Author:
helen
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-views.js

    r29568 r29582  
    52545254
    52555255            this.listenTo( this.controller, 'library:selection:add',    this.attachmentFocus );
    5256             this.listenTo( this.controller, 'attachment:keydown:arrow', this.arrowEvent );
    52575256
    52585257            // Throttle the scroll handler and bind this.
     
    52825281        arrowEvent: function( event ) {
    52835282            var attachments = this.$el.children( 'li' ),
    5284                 perRow = Math.round( this.$el.width() / attachments.first().outerWidth() ),
     5283                perRow = this.$el.data( 'columns' ),
    52855284                index = attachments.filter( ':focus' ).index(),
    52865285                row = ( index + 1 ) <= perRow ? 1 : Math.ceil( ( index + 1 ) / perRow );
     5286
     5287            if ( index === -1 ) {
     5288                return;
     5289            }
    52875290
    52885291            // Left arrow
     
    60016004                AttachmentView: this.options.AttachmentView
    60026005            });
     6006
     6007            // Add keydown listener to the instance of the Attachments view
     6008            this.attachments.listenTo( this.controller, 'attachment:keydown:arrow', this.attachments.arrowEvent );
    60036009
    60046010            this.views.add( this.attachments );
Note: See TracChangeset for help on using the changeset viewer.