Customize: Temporary fix for autosave restore notice not being removed

Fixes the "There is a more recent autosave of your changes" notice from not
being removed when the dismiss button is clicked.

The problem is caused by the notice being initialized twice: once by the
`common` script and then again by the `customize-controls` script.

This temporary fix prevents `customize-controls` from initializing a notice if
it has already been initialized.

A better fix would be to not initialize notices twice. This can be done by
removing `common` as a dependency of `updates` when `deprecateL10nObject` is
removed.

When this happens (est: 5.7), this temporary fix should be reverted.

Fixes #51425.
See #51317.
Props karthikbhatb, dlh, SergeyBiryukov.


git-svn-id: https://develop.svn.wordpress.org/trunk@49625 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Robert Anderson 2020-11-17 04:43:33 +00:00
parent ac71fffac0
commit 6b6a643b0b

View File

@ -1094,6 +1094,10 @@ $document.ready( function() {
var $el = $( this ),
$button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' );
if ( $el.find( '.notice-dismiss' ).length ) {
return;
}
// Ensure plain text.
$button.find( '.screen-reader-text' ).text( __( 'Dismiss this notice.' ) );
$button.on( 'click.wp-dismiss-notice', function( event ) {