New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta Boxes: Remove dirty detection #10220

merged 1 commit into from Oct 4, 2018


None yet
3 participants

aduth commented Sep 27, 2018

This pull request seeks to remove dirty detection for meta boxes. This is a feature which never existed in the classic editor but was introduced to Gutenberg as a proposed enhancement in an effort to avoid content loss. In practice, it has been shown to be very unreliable, very often prompting the user about unsaved changes when not exist, degrading the user experience.

In most cases, this occurs because plugins programmatically manipulate the values of inputs in the DOM after the editor has loaded. This conflicts with the dirty detection, which operates as a diff of input values between the initial load (or last save) and when the user attempts to leave the page. To my knowledge, it is not possible to differentiate between user initiated input changes and those incurred programmatically, nor is it possible to identify a point in time where it can be definitively determined that plugins are truly initialized so far as their post-initialization behaviors.

Testing instructions

Normally, this would be very easy to observe and test in the Yoast plugin, which assigns a hidden input value after initial load as the result of an AJAX request initiated after page load. However, with deprecations removed in the latest version of the master branch, the Yoast meta box does not currently load.

Instead, consider including the following plugin in wp-content/mu-plugins or wp-content/plugins:


 * Plugin name: Demo Meta

function demo_meta_box_add() {
		'My First Meta Box',
add_action( 'add_meta_boxes', 'demo_meta_box_add' );

function demo_meta_box_callback() {
    echo '<input name=foo>';   

Verify both:

  • the reloading the page after entering text in the input does not trigger a prompt
  • that a network request sending meta box input values is triggered upon saving the post †

† In this very naïve test plug-in, there is no persistence of the meta input value. Therefore, it is not expected that the value be restored after the page is reloaded, even if the post is saved.

@aduth aduth added this to the 4.0 milestone Oct 3, 2018


I love this PR. It simplifies a lot of the code.

It works great in my testing.

@youknowriad youknowriad merged commit cc00a68 into master Oct 4, 2018

2 checks passed

codecov/project 49.41% (-0.02%) compared to d6af165
continuous-integration/travis-ci/pr The Travis CI build passed

@youknowriad youknowriad deleted the remove/meta-dirty-detect branch Oct 4, 2018


This comment has been minimized.

Show comment
Hide comment

omarreiss Oct 5, 2018


Haven't been able to take a look, but very happy with this merge!


omarreiss commented Oct 5, 2018

Haven't been able to take a look, but very happy with this merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment