gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

KSES filters force a dirty state in the editor

Open mmtr opened this issue 7 years ago • 3 comments

Describe the bug

As of Gutenberg 6.4.0, the KSES filters are making the editor to believe there are unsaved changes where there are none.

These filters are only registered when a user doesn't have the unfiltered_html capability (which is the case for multisite regular admins).

When these filters are active, syntax like <img src="..." class="..."/> (produced by the core/image block) is transformed to <img src="..." class="..." /> (note the extra whitespace at the end).

That extra whitespace is putting the editor in dirty state, but it seems that those whitespaces were ignored on Gutenberg 6.3.0 and below.

To reproduce

  1. Activate Gutenberg 6.4.0 on a multisite install, or test with a user not having the unfiltered_html capability.

  2. Add a new post and insert an image block.

  3. Publish the post.

  4. Note how the publish sidebar is automatically hidden.

  5. Note how the "Update" button is enabled, despite not having entered any change.

  6. Run wp.data.select('core/editor').getEditedPostAttribute('content') and wp.data.select('core/editor').getCurrentPostAttribute('content') on the browser devtools console.

  7. Note how the current post content contains an extra whitespace: Screen Shot 2019-08-30 at 10 40 52

  8. Run wp.data.select('core/editor').isEditedPostDirty() on the browser devtools console.

  9. Note how the above command returns true.

Expected behavior The same behavior we had in Gutenberg 6.3.0 and below:

  • The publish sidebar shouldn't disappear in 4.
  • The "Update" button should be disabled in 5.
  • isEditedPostDirty should return false in 8.

mmtr avatar Aug 30 '19 05:08 mmtr

Related: #15137.

kwight avatar Sep 09 '19 15:09 kwight

Maybe related: #17491

bvlgn avatar Sep 20 '19 21:09 bvlgn

This is no longer reproducible, probably solved by https://github.com/WordPress/gutenberg/pull/17532

mmtr avatar Oct 08 '19 15:10 mmtr