Make WordPress Core

Changeset 42144 for trunk


Ignore:
Timestamp:
11/10/2017 09:43:32 PM (9 years ago)
Author:
westonruter
Message:

Customize: Ensure autosave revision is dismissed immediately after implicit restoration notice dismissal as done with explicit notice dismissal.

Fixes issue where a drafted/scheduled changeset could inadvertently re-use the previous autosave revision in the preview while a user expects it to have been dismissed.

See #39896, [41597].
Fixes #42502 for trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r42136 r42144  
    82498249                // Set up initial notifications.
    82508250                (function() {
    8251                         var removedQueryParams = [];
     8251                        var removedQueryParams = [], autosaveDismissed = false;
    82528252
    82538253                        /**
     
    82968296
    82978297                        /**
     8298                         * Dismiss autosave.
     8299                         *
     8300                         * @returns {void}
     8301                         */
     8302                        function dismissAutosave() {
     8303                                if ( autosaveDismissed ) {
     8304                                        return;
     8305                                }
     8306                                wp.ajax.post( 'customize_dismiss_autosave_or_lock', {
     8307                                        wp_customize: 'on',
     8308                                        customize_theme: api.settings.theme.stylesheet,
     8309                                        customize_changeset_uuid: api.settings.changeset.uuid,
     8310                                        nonce: api.settings.nonce.dismiss_autosave_or_lock,
     8311                                        dismiss_autosave: true
     8312                                } );
     8313                                autosaveDismissed = true;
     8314                        }
     8315
     8316                        /**
    82988317                         * Add notification regarding the availability of an autosave to restore.
    82998318                         *
     
    83208339
    83218340                                                // Handle dismissal of notice.
    8322                                                 li.find( '.notice-dismiss' ).on( 'click', function() {
    8323                                                         wp.ajax.post( 'customize_dismiss_autosave_or_lock', {
    8324                                                                 wp_customize: 'on',
    8325                                                                 customize_theme: api.settings.theme.stylesheet,
    8326                                                                 customize_changeset_uuid: api.settings.changeset.uuid,
    8327                                                                 nonce: api.settings.nonce.dismiss_autosave_or_lock,
    8328                                                                 dismiss_autosave: true
    8329                                                         } );
    8330                                                 } );
     8341                                                li.find( '.notice-dismiss' ).on( 'click', dismissAutosave );
    83318342
    83328343                                                return li;
     
    83368347                                // Remove the notification once the user starts making changes.
    83378348                                onStateChange = function() {
     8349                                        dismissAutosave();
    83388350                                        api.notifications.remove( code );
    83398351                                        api.unbind( 'change', onStateChange );
Note: See TracChangeset for help on using the changeset viewer.