Skip to content

Preserve nested list when deleting a selection across sibling list items#78776

Merged
ellatrix merged 4 commits into
trunkfrom
fix/sibling-list-merge-drops-nested-list
Jun 9, 2026
Merged

Preserve nested list when deleting a selection across sibling list items#78776
ellatrix merged 4 commits into
trunkfrom
fix/sibling-list-merge-drops-nested-list

Conversation

@ellatrix

Copy link
Copy Markdown
Member

What?

Fix a nested list being dropped when deleting a text selection that spans two sibling list items.

Why?

Deleting a multi-block text selection merged only block attributes, so inner blocks (e.g. a nested list) on the block merged away were lost. Backspace dropped them; Delete only kept them because the target happened to be the item that owned the nested list.

How?

In __unstableDeleteSelection, carry both blocks' inner blocks (in document order) onto the surviving merged block.

Testing Instructions

  1. Create a list with items "ab" and "cd", and nest a "test" item under "cd".
  2. Select text spanning "ab" and "cd" (e.g. from inside "ab" to inside "cd").
  3. Press Backspace.
  4. The items merge and the nested "test" list is preserved.

Testing Instructions for Keyboard

Make the selection in step 2 with shift+arrow keys.

Use of AI Tools

Authored with Claude Code (Claude Opus 4.7).

@github-actions

Copy link
Copy Markdown

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: ellatrix <ellatrix@git.wordpress.org>

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

@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label May 28, 2026
@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown

Size Change: +9 B (0%)

Total Size: 8.44 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 380 kB +9 B (0%)

compressed-size-action

When deleting a multi-block text selection, the merge only combined block
attributes, so inner blocks (e.g. a nested list) on the block merged away
were dropped. Carry both blocks' inner blocks onto the surviving block.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ellatrix ellatrix force-pushed the fix/sibling-list-merge-drops-nested-list branch from 01fd1f2 to 0dce463 Compare May 28, 2026 14:09
ellatrix and others added 3 commits June 8, 2026 12:44
The merged result should keep only the inner blocks of the block whose
text remains after the selection end; the first block's inner blocks
sit inside the selected range and should be deleted with it. Add a
test covering that case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Flaky tests detected in fd6d05f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/27132728887
📝 Reported issues:

@ellatrix ellatrix merged commit 5e84a8d into trunk Jun 9, 2026
40 checks passed
@ellatrix ellatrix deleted the fix/sibling-list-merge-drops-nested-list branch June 9, 2026 10:18
@github-actions github-actions Bot added this to the Gutenberg 23.4 milestone Jun 9, 2026
@ramonjd ramonjd added the [Type] Bug An existing feature does not function as intended label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants