Editor: Correct the check for unsaved content in wp.autosave.server.postChanged().

This fixes improper triggering of the "Are you sure?" prompt when navigating away from the old, "classic" Edit Post screen and there are no changes.

The previous check did not account for Pages or any custom post types that don't have a Title, Content, or Excerpt field.

Follow-up to [50031].

Props hwk-fr, mukesh27, audrasjb, archon810, Clorith, ibiza69, tonysandwich, roger995, bartosz777, viablethought, dbtedg, worldedu, hmabpera, magnuswebdesign.
Fixes #52440.
Built from https://develop.svn.wordpress.org/trunk@50232


git-svn-id: http://core.svn.wordpress.org/trunk@49893 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-02-06 14:16:07 +00:00
parent a8d455a78f
commit 1aca7e8b25
3 changed files with 4 additions and 4 deletions

View File

@ -710,7 +710,7 @@ window.autosave = function() {
var editor = window.tinymce.get( field ); var editor = window.tinymce.get( field );
if ( ! editor || editor.isHidden() ) { if ( ! editor || editor.isHidden() ) {
if ( $( '#' + field ).val() !== initialCompareData[ field ] ) { if ( ( $( '#' + field ).val() || '' ) !== initialCompareData[ field ] ) {
changed = true; changed = true;
// Break. // Break.
return false; return false;
@ -721,7 +721,7 @@ window.autosave = function() {
} }
} ); } );
if ( $( '#title' ).val() !== initialCompareData.post_title ) { if ( ( $( '#title' ).val() || '' ) !== initialCompareData.post_title ) {
changed = true; changed = true;
} }

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.7-beta1-50231'; $wp_version = '5.7-beta1-50232';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.