From b301fa3d4263244a77f6c28fabe7494ec6735c69 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 6 Feb 2021 14:14:48 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@50232 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/wp/autosave.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/_enqueues/wp/autosave.js b/src/js/_enqueues/wp/autosave.js index a1bd570c68..1a57ead46a 100644 --- a/src/js/_enqueues/wp/autosave.js +++ b/src/js/_enqueues/wp/autosave.js @@ -710,7 +710,7 @@ window.autosave = function() { var editor = window.tinymce.get( field ); if ( ! editor || editor.isHidden() ) { - if ( $( '#' + field ).val() !== initialCompareData[ field ] ) { + if ( ( $( '#' + field ).val() || '' ) !== initialCompareData[ field ] ) { changed = true; // Break. return false; @@ -721,7 +721,7 @@ window.autosave = function() { } } ); - if ( $( '#title' ).val() !== initialCompareData.post_title ) { + if ( ( $( '#title' ).val() || '' ) !== initialCompareData.post_title ) { changed = true; }