WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.21k forks source link

Invalid markup in Classic editor results in no content in editor when Gutenberg activated #12275

Open dreamwhisper opened 5 years ago

dreamwhisper commented 5 years ago

Describe the bug If there is invalid markup such as a missing " in the Classic editor, when activating the Gutenberg plugin or updating to RC1, the result is that content after that error is removed from the post.

To Reproduce Steps to reproduce the behavior:

  1. Create a post containing invalid HTML in the Classic Editor text tab. See example below.
  2. Activate Gutenberg 4.5.1 or WordPress 5.0 RC1
  3. Return to the post edit screen.
  4. Only the first paragraph of content is visible even in code editor.
<p>This is an example of a WordPress post.</p>
<p class="intro>This is an example of a WordPress post.</p>
<p>This is an example of a WordPress post.</p>

Expected behavior All content will be visible so you can correct the error. As of now, it seems to simply delete everything after the invalid portion.

Desktop

OS: Windows/OSX
Browser: Chrome/FF 
Version: Latest

Additional context Gutenberg 4.5.1 or WordPress 5.0 RC1

designsimply commented 5 years ago

I tested with WordPress 4.9.8 and Gutenberg 4.5.1 using Firefox 63.0.3 on macOS 10.13.6 and found that when I add the sample HTML provided into a classic block in "Edit as HTML" mode that it prompts me to either restore or convert to HTML.

12275 Seen at https://tan-otter.jurassic.ninja/wp-admin/post.php?post=111&action=edit running WordPress 4.9.8 and Gutenberg 4.5.1 using Firefox 63.0.3 on macOS 10.13.6.

Leaving the Needs Testing label for now and noting we should also get a tester to check from Windows.

designsimply commented 5 years ago

Aha, I just realized I missed a step in the instructions which was to disable Gutenberg before adding the sample HTML. So I re-tested and confirmed that creating a post with invalid HTML content using the Text editor in WordPress 4.9.8 without Gutenberg and then activating Gutenberg and opening the post results in the content from the invalid HTML forward to be removed.

12275-2 Seen at https://tan-otter.jurassic.ninja/wp-admin/post.php?post=112&action=edit running WordPress 4.9.8 and Gutenberg 4.5.1 using Firefox 63.0.3 on macOS 10.13.6.

Note: it's possible this is the intended behavior.

dreamwhisper commented 5 years ago

Note: it's possible this is the intended behavior.

We see varying degrees of HTML errors in content when reviewing customer theme support requests, including this example. For non-technical users editing previously written content, missing content is unexpected and I wouldn't expect them to know how to resolve it.

I don't know if the content removal extends beyond a missing quote, but there's no indication that any content has been removed, and if the content is long, they may not realize it is missing initially.

aduth commented 5 years ago

Another way to trigger this, particularly now that Gutenberg is available in the stable WordPress 5.0 release, is by pasting the text from the original content in the "Code Editor" of the new post editor screen.

After leaving the field, all but the first paragraph of text is removed.

it's not entirely clear to me at the moment what precisely an expected behavior would be, since Gutenberg is unable to process the content as valid HTML.

Browsers behave in much the same way as what's seen in Gutenberg: https://codepen.io/aduth/pen/gqXVxo

I must then think that something about the previous editor (likely in TinyMCE itself?) had applied a very specific correction to the content.