Some content gets lost when the editor automatically updates old HTML #48137
Description
Description
If I look at the revisions for a blog post on my website that hasn't been edited in several months, I see that (the way the post is currently saved) the HTML for bulleted lists looks different from how it would look now. If I go to edit the post, and I look at it in the code editor, the HTML that the editor is working with is automatically updated. So far, so good.
It goes from something like this...
<!-- wp:list -->
<ul><li>First</li><li>Second</li><li>Third</li></ul>
<!-- /wp:list -->
...to something like this.
<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>First</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>Second</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>Third</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->
In some cases, though, some of the content of the list seems to be getting lost during this process. I've only seen this problem happen in cases where a list contains a shortcode for a footnote plugin I'm using, which looks like this: [efn_note]Footnote text here[/efn_note]
(I don't think this bug really has much to do with that plugin, though. You can still reproduce the bug by following the instructions below, but without using that exact shortcode.)
I think the bug may only happen in cases where the text inside the footnote shortcode also includes a link.
This bug prevents me from editing an old blog post continuing from how I last saved it, since as soon as the post is opened in the editor, some of the content that exists in the most recently published version of the post gets deleted from the editor.
Step-by-step reproduction instructions
To exactly reproduce the problem I'm having, I guess you'd have to have an old page or post that hasn't had an edit saved in months, and that contains the right combination of the right kinds of lists and footnotes and links... But maybe this will be close enough:
- Create a new page or post.
- Switch to the code editor.
- Paste this code:
<!-- wp:list -->
<ul><li>First[efn_note]This is a <a href="https://www.example.com">note</a>.[/efn_note]</li><li>Second</li></ul>
<!-- /wp:list -->
- Click outside of the box where you put the code. The code is automatically converted to the format WordPress currently uses for lists, but at the same time, all the list content after "First" disappears.
<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>First</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->
Screenshots, screen recording, code snippet
No response
Environment info
I'm not using the Gutenberg plugin, just the block editor built into WordPress.
WordPress version 6.1.1 with Twenty Thirteen theme
Firefox, Chrome, Edge
Laptop with Windows 10
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Activity