WordPress / gutenberg

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

List: Deleting an empty item at the top of a (malformed) list reshuffles the block #55757

Open jasmussen opened 11 months ago

jasmussen commented 11 months ago

This one is hard to describe, so it's best to test. Here's testing content:

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Item<!-- wp:list -->
<ul><!-- wp:list-item -->
<li></li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Item</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Item</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Item</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Item 2<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Item</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Item</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

This will create two list items in a list, each item with further nested list items.

Notably the first nested list item of the first list item is empty. If you set focus on that block and press "backspace", suddenly you are focused in a new empty top level list item, as item 2. Expectation would be the list item was simply deleted.

GIF showing the above:

list view bug

jasmussen commented 11 months ago

@ellatrix do you know what this might be?

jordesign commented 11 months ago

Confirmed this one in testing with both WP 6.3.2 and 6.4RC3 - definitely an odd one.

ellatrix commented 11 months ago

@jasmussen That's because the list is malformed. In the list view you can see that the first list item contains two lists instead of just one. Instead of fixing the symptoms, it would be good to figure out how you ended up with this state. How did you create this list, step by step?

Screenshot 2023-11-06 at 11 32 32
jasmussen commented 11 months ago

I got to this state by copying from Google Docs. I find this happens somewhat often, I usually take notes in a list form similar to the above, and when copying over those lists this happens. Feel free to DM me and I can send you the specific Google Doc I used to copy over.