Skip to content

List Item Block: Fix deletion of empty list items with nested children#71482

Closed
dhruvikpatel18 wants to merge 1 commit intoWordPress:trunkfrom
dhruvikpatel18:fix/deleting-empty-list-item-block
Closed

List Item Block: Fix deletion of empty list items with nested children#71482
dhruvikpatel18 wants to merge 1 commit intoWordPress:trunkfrom
dhruvikpatel18:fix/deleting-empty-list-item-block

Conversation

@dhruvikpatel18
Copy link
Copy Markdown
Contributor

@dhruvikpatel18 dhruvikpatel18 commented Sep 3, 2025

Closes #56223

What?

Fixes the deletion behavior of empty list items that contain nested sub-items, ensuring nested items are promoted to top-level instead of being deleted entirely.

Why?

Currently, when you delete an empty list item at the top of a nested list structure, all nested items underneath are also deleted. This is unexpected behavior - users expect the nested items to be promoted to become top-level list items instead of being lost entirely. This creates a poor user experience and potential data loss.

Testing Instructions

  1. Open a post or page in the block editor
  2. Insert a List block
  3. Add a few list items with text
  4. Create nested items by indenting some items (use Tab or the indent button)
  5. Clear the content of the top-level item that has nested children (make it completely empty)
  6. Press Backspace or Delete to remove the empty item
  7. Verify that the nested items are promoted to become top-level items instead of being deleted

Screenshots or screencast

Before

List.Item.block.before.mov

After

List.Item.block.after.mov

@im3dabasia im3dabasia added [Type] Bug An existing feature does not function as intended [Block] List Affects the List Block and removed [Block] List Affects the List Block labels Sep 3, 2025
@dhruvikpatel18 dhruvikpatel18 marked this pull request as ready for review September 4, 2025 05:08
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 4, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhruvikpatel18 <dhruvik18@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@annezazu
Copy link
Copy Markdown
Contributor

annezazu commented Nov 8, 2025

This worked great for me while testing! Thanks for working on it. @Mamaduka is this something you could quickly review?

@Mamaduka
Copy link
Copy Markdown
Member

Mamaduka commented Dec 9, 2025

Sorry for the late reply. Looking at the failing e2e tests, they seem to be related to this change. We shouldn't regress other functionality, while fixing bugs :)

@dhruvikpatel18, do you mind rebasing this branch on top of the latest trunk?

@Mamaduka
Copy link
Copy Markdown
Member

Closing this now that #73839 is merged. I've included @dhruvikpatel18 in the props list.

Thanks again, @dhruvikpatel18!

@Mamaduka Mamaduka closed this Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] List Affects the List Block [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List Block: deleting an empty list block at the top of a list deletes all items within it

4 participants