Make WordPress Core

Changeset 50366


Ignore:
Timestamp:
02/16/2021 08:22:36 PM (2 years ago)
Author:
desrosj
Message:

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.
Merges [50232] to the 5.6 branch.
Fixes #52440.

Location:
branches/5.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

  • branches/5.6/src/js/_enqueues/wp/autosave.js

    r50031 r50366  
    711711
    712712                        if ( ! editor || editor.isHidden() ) {
    713                             if ( $( '#' + field ).val() !== initialCompareData[ field ] ) {
     713                            if ( ( $( '#' + field ).val() || '' ) !== initialCompareData[ field ] ) {
    714714                                changed = true;
    715715                                // Break.
     
    722722                    } );
    723723
    724                     if ( $( '#title' ).val() !== initialCompareData.post_title ) {
     724                    if ( ( $( '#title' ).val() || '' ) !== initialCompareData.post_title ) {
    725725                        changed = true;
    726726                    }
Note: See TracChangeset for help on using the changeset viewer.