Make WordPress Core

Changeset 23283


Ignore:
Timestamp:
01/04/2013 11:29:20 PM (10 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).

props koopersmith.
fixes #23054.
for trunk.

File:
1 edited

Legend:

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

    r23263 r23283  
    28472847            var selection = this.options.selection;
    28482848
    2849             this.model.on( 'change:sizes change:uploading change:caption change:title', this.render, this );
     2849            this.model.on( 'change:sizes change:uploading', this.render, this );
     2850            this.model.on( 'change:title', this._syncTitle, this );
     2851            this.model.on( 'change:caption', this._syncCaption, this );
    28502852            this.model.on( 'change:percent', this.progress, this );
    28512853
     
    31653167    });
    31663168
     3169    // Ensure settings remain in sync between attachment views.
     3170    _.each({
     3171        caption: '_syncCaption',
     3172        title:   '_syncTitle'
     3173    }, function( method, setting ) {
     3174        media.view.Attachment.prototype[ method ] = function( model, value ) {
     3175            var $setting = this.$('[data-setting="' + setting + '"]');
     3176
     3177            if ( ! $setting.length )
     3178                return this;
     3179
     3180            // If the updated value is in sync with the value in the DOM, there
     3181            // is no need to re-render. If we're currently editing the value,
     3182            // it will automatically be in sync, suppressing the re-render for
     3183            // the view we're editing, while updating any others.
     3184            if ( value === $setting.find('input, textarea, select, [value]').val() )
     3185                return this;
     3186
     3187            return this.render();
     3188        };
     3189    });
     3190
    31673191    /**
    31683192     * wp.media.view.Attachment.Library
Note: See TracChangeset for help on using the changeset viewer.