WordPress.org

Make WordPress Core

Changeset 23284


Ignore:
Timestamp:
01/04/13 23:31:52 (2 years ago)
Author:
nacin
Message:

Don't unnecessarily re-render the attachment details view when editing the title and caption. Re-rendering causes issues with tabbing and focus, and is only necessary for other views (such as "Caption this image..." when editing a gallery).

Merges [23283] to the 3.5 branch.

props koopersmith.
fixes #23054.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.5/wp-includes/js/media-views.js

    r23273 r23284  
    28432843            var selection = this.options.selection; 
    28442844 
    2845             this.model.on( 'change:sizes change:uploading change:caption change:title', this.render, this ); 
     2845            this.model.on( 'change:sizes change:uploading', this.render, this ); 
     2846            this.model.on( 'change:title', this._syncTitle, this ); 
     2847            this.model.on( 'change:caption', this._syncCaption, this ); 
    28462848            this.model.on( 'change:percent', this.progress, this ); 
    28472849 
     
    31613163    }); 
    31623164 
     3165    // Ensure settings remain in sync between attachment views. 
     3166    _.each({ 
     3167        caption: '_syncCaption', 
     3168        title:   '_syncTitle' 
     3169    }, function( method, setting ) { 
     3170        media.view.Attachment.prototype[ method ] = function( model, value ) { 
     3171            var $setting = this.$('[data-setting="' + setting + '"]'); 
     3172 
     3173            if ( ! $setting.length ) 
     3174                return this; 
     3175 
     3176            // If the updated value is in sync with the value in the DOM, there 
     3177            // is no need to re-render. If we're currently editing the value, 
     3178            // it will automatically be in sync, suppressing the re-render for 
     3179            // the view we're editing, while updating any others. 
     3180            if ( value === $setting.find('input, textarea, select, [value]').val() ) 
     3181                return this; 
     3182 
     3183            return this.render(); 
     3184        }; 
     3185    }); 
     3186 
    31633187    /** 
    31643188     * wp.media.view.Attachment.Library 
Note: See TracChangeset for help on using the changeset viewer.