WordPress.org

Make WordPress Core

Changeset 50232


Ignore:
Timestamp:
02/06/2021 02:14:48 PM (10 months ago)
Author:
SergeyBiryukov
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.
Fixes #52440.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/autosave.js

    r49807 r50232  
    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.