[wp-trac] [WordPress Trac] #59094: postChanged() is not working correctly in Text mode editor

WordPress Trac noreply at wordpress.org
Sun Aug 13 13:40:12 UTC 2023


#59094: postChanged() is not working correctly in Text mode editor
--------------------------+-----------------------------
 Reporter:  skylex69      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Autosave      |    Version:  6.3
 Severity:  major         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The javascript function `wp.autosave.server.postChanged()` from
 autosave.js always returns `true` if we change the post content in
 **Text** mode in the classic editor, even after autosave kicked-in as seen
 with "Draft saved at ...".

 It is supposed to return `false` after the post has been autosaved.

 If you switch to **Visual** mode editor, the function immediately returns
 `false` and after any content change, it switches from `true` to `false`
 in a few seconds.

 Easy steps to reproduce:
 – open the editor on any post
 – change the post content in Text (not Visual) mode
 – wait for autosave to kick in (watch the editor status bar)
 – in the browser console, type: `wp.autosave.server.postChanged()`
 – it will return `true`
 – switch to Visual mode editor
 – same command will return `false` (meaning “autosave” is OK)
 – switch back to Text mode editor
 – same command will return `true` again, even if you didn’t change
 anything more

 Tested on a brand new WP 6.3 default install with Twentytwentythree theme.

 It causes an issue when I try to schedule a new revision with the plugin
 PublishPress Revisions in Text mode after changing the post content. The
 button hangs and the revision never gets saved. The workaround is to click
 on the Visual tab to unstuck the button. The JS code of this plugin is
 checking postChanged(), if true it triggers an autosave with
 triggerSave(), waits 250ms and checks again if postChanged() is false. If
 not, it hangs.

 Also, this bug causes the editor to always warn you (with a javascript
 prompt) about unsaved content in Text mode if you try to close the tab or
 change the URL after having changed the post content, even after it has
 been autosaved.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59094>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list