Make WordPress Core

Changeset 29299


Ignore:
Timestamp:
07/25/2014 12:59:29 AM (10 years ago)
Author:
wonderboymusic
Message:

Media Grid: when closing the modal, automatically focus the proper attachment by reading the model's ID, which is unique.

Props adamsilverstein (for the red), wonderboymusic (for the green).
Fixes #28857.

Location:
trunk/src/wp-includes/js
Files:
2 edited

Legend:

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

    r29282 r29299  
    176176                frame:       'edit-attachments',
    177177                gridRouter:  this.gridRouter,
    178                 gridItem:    $( currentTarget ).closest( 'li' ),
    179178                library:     this.state().get('library'),
    180179                model:       model
     
    369368            });
    370369
    371             this.gridItem = this.options.gridItem;
    372370            this.gridRouter = this.options.gridRouter;
    373371            this.library = this.options.library;
     
    407405                    $( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */
    408406                    // Restore the original focus item if possible
    409                     self.gridItem && self.gridItem.focus();
     407                    $( 'li.attachment[data-id="' + self.model.get( 'id' ) +'"]' ).focus();
    410408                    self.resetRoute();
    411409                } );
  • trunk/src/wp-includes/js/media-views.js

    r29289 r29299  
    46404640                    rerenderOnModelChange: true
    46414641                } );
    4642             this.$el.attr( 'aria-label', this.model.get( 'title' ) ).attr( 'aria-checked', false );
     4642            this.$el.attr( {
     4643                'aria-label'  : this.model.get( 'title' ),
     4644                'aria-checked': false,
     4645                'data-id'     : this.model.get( 'id' )
     4646            } );
    46434647
    46444648            if ( options.rerenderOnModelChange ) {
Note: See TracChangeset for help on using the changeset viewer.