Make WordPress Core

Opened 11 months ago

#59094 new defect (bug)

postChanged() is not working correctly in Text mode editor

Reported by: skylex69's profile skylex69 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 6.3
Component: Autosave Keywords:
Focuses: Cc:


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.

Attachments (1)

Capture d’écran 2023-08-13 à 15.12.33.png (495.4 KB) - added by skylex69 11 months ago.

Download all attachments as: .zip

Change History (1)

Note: See TracTickets for help on using tickets.