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. Built from https://develop.svn.wordpress.org/trunk@29299 git-svn-id: http://core.svn.wordpress.org/trunk@29081 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9436186ee4
commit
0e4c8b2b0c
|
@ -175,7 +175,6 @@
|
|||
wp.media( {
|
||||
frame: 'edit-attachments',
|
||||
gridRouter: this.gridRouter,
|
||||
gridItem: $( currentTarget ).closest( 'li' ),
|
||||
library: this.state().get('library'),
|
||||
model: model
|
||||
} );
|
||||
|
@ -368,7 +367,6 @@
|
|||
state: 'edit-attachment'
|
||||
});
|
||||
|
||||
this.gridItem = this.options.gridItem;
|
||||
this.gridRouter = this.options.gridRouter;
|
||||
this.library = this.options.library;
|
||||
if ( this.options.model ) {
|
||||
|
@ -406,7 +404,7 @@
|
|||
self.modal.remove();
|
||||
$( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */
|
||||
// Restore the original focus item if possible
|
||||
self.gridItem && self.gridItem.focus();
|
||||
$( 'li.attachment[data-id="' + self.model.get( 'id' ) +'"]' ).focus();
|
||||
self.resetRoute();
|
||||
} );
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4639,7 +4639,11 @@
|
|||
options = _.defaults( this.options, {
|
||||
rerenderOnModelChange: true
|
||||
} );
|
||||
this.$el.attr( 'aria-label', this.model.get( 'title' ) ).attr( 'aria-checked', false );
|
||||
this.$el.attr( {
|
||||
'aria-label' : this.model.get( 'title' ),
|
||||
'aria-checked': false,
|
||||
'data-id' : this.model.get( 'id' )
|
||||
} );
|
||||
|
||||
if ( options.rerenderOnModelChange ) {
|
||||
this.model.on( 'change', this.render, this );
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue