WordPress 5.6.1 Introduces Bug Into Post and Page Windows


WordPress 5.6.1, which many sites auto-updated to, has introduced a bug that makes it difficult to save a post. A temporary patch has been created to address the issue but it’s not an official update to solve the problem.

Changes You Made May Not Be Saved

A bug introduced into the latest version of WordPress, version 5.6.1 causes an alert to pop up when attempting to navigate away, regardless if the post has been saved or not.

The bug was reported in a WordPress support page:

“I am getting the pop up “Leave Site? Changes you made may not be saved. All the time, if I change a page or not, and if I save (publish or update) the page or not.

This began after the 5.6.1 upgrade this morning. I have 2 sites, with 2 different themes, both with the classic editor 1.6 and it behaves the same on both.

It does this in Chrome, it does not do it in Firefox.”

Advertisement

Continue Reading Below

The fact that it doesn’t happen in Firefox is interesting because Firefox handles certain aspects of the unload event differently from Chrome in that Chrome lacks certain features.

As an example, within the beforeunload event when activated with event.preventDefault() works with Firefox but not with Chrome. https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event

I’m not saying the above is the issue. Just pointing out that Firefox supports some features that Chrome does not.

Unload Events Bug in WordPress Editing Window?

The notice is part of what’s called an “unload event” that triggers a warning when a publisher tries to navigate away from a window, usually when something is left undone.

The exact warning message triggered is:

Advertisement

Continue Reading Below

“Leave Site? Changes you made may not be saved.”

The bug manifests itself in both posts and pages. But some publishers have reported that the bug is only present when editing page content and works fine when editing post content.

According to several reports the bug could be triggered by editing related plugins like Tiny MCE and Advanced Custom Fields. Turning off those plugins stops the unload message from spawning.

A publisher reported in the private Advanced WordPress Facebook group that turning off the Advanced Custom Fields plugin stopped the warning from spawning.

But the problem is not with the plugins themselves. The problem appears to be within the WordPress core itself which is causing the problem to manifest in different editing related windows.

One publisher reported relief by turning on the Gutenberg editing environment:

“Do You Want to Leave This Site? Changes you made may not be saved” Alert notice on leaving updated pages (but not posts) after 5.6.1 update when using classic editor. …Goes away when Gutenberg is turned back on.”

Another publisher noted that WordPress editing related plugins seemed to trigger the bug:

“Update: It looks like the user has to wait for TinyMCE to entirely load before making a change, otherwise the script doesn’t take his change into account.

A good visual hint is the dropshadow of toolbar which dispear once the editor is correctly initialized.”

One user uploaded a video of a walkthrough showing how the bug is spawned. In the video the publisher chooses a document to edit and enters the editing window.

Advertisement

Continue Reading Below

The publisher next presses the update button to save the page. They next click a link to navigate away from the editing window.

But that act causes the unload warning message to spawn.

Below is an animated gif of the movie that was uploaded showing the walkthrough of the bug:

Screenshot Animation of WordPress 5.6.1 Editing Window Bug

Temporary Solution Has Been Posted

A patch has been posted to WordPress, but it is not an official fix.

Advertisement

Continue Reading Below

This version of the patch is fully functional. It’s code that needs to be inserted into the functions.php file.

There is another patch that was shared that addresses an additional issue but it has not been fully tested.

WordPress 5.6.1 Changes Made Not Saved Bug

If the issue is hindering your workflow, there are steps that can be taken. One recommended step could be to wait to make sure that all editing related plugins are fully loaded. Other actions include disabling editing related plugins or turning on Gutenberg.

There is a patch that can be applied to functions.php and lastly one can wait for an official patch.

Citations

WordPress Support Page Discussion
Changes You Made May Not Be Saved

Advertisement

Continue Reading Below

Official WordPress Bug Report Page
“Leave site? Changes you made may not be saved” on custom taxonomy pages after WP 5.6.1 update





Source