Skip to content

Block editor: keep inner blocks when splitting a selection merges blocks - #81000

Open
ellatrix wants to merge 5 commits into
trunkfrom
fix/split-selection-inner-blocks
Open

ellatrix wants to merge 5 commits into
trunkfrom
fix/split-selection-inner-blocks

Conversation

@ellatrix

@ellatrix ellatrix commented Jul 31, 2026 •

Copy link
Copy Markdown
Member

What?

Fixes #26713. Pasting a block that has inner blocks into text no longer drops the inner blocks: a copied list item keeps its nested list.

Why?

__unstableSplitSelection merges the first and last pasted blocks into the surrounding text (introduced in #54543), but the merge only joins attributes: the merged blocks' inner blocks were discarded. This is the paste-side counterpart of #77245, which fixed the merge machinery dropping children on Delete. It also dropped a split half whose attributes were untouched even when it still held children, losing the target's own nested list when pasting at the end of an item.

How?

The head and tail merges carry over the merged block's inner blocks, and an attribute-unmodified tail is kept when it still has children. Following the rule from #78776: the head never carries the first block's own inner blocks, since they sit after its text — within a ranged selection they are deleted with it, and for a collapsed selection they belong to the trailing half.

When pasting at the end of an item whose children belonged to the trailing half, those children now survive on an empty trailing item. Reattaching them to the preceding item would be a separate reparenting decision.

Testing Instructions

  1. Create a list with two items, the second containing a nested list.
  2. Select the second item as a block (Escape) and copy it.
  3. Place the caret at the start of the first item and paste.
  4. The pasted item keeps its nested list; previously the nested list was silently lost.

Covered by regression tests for both the caret and the ranged selection case; they fail on trunk.

Use of AI Tools

Written with Claude Code, reviewed and tested by me.

ellatrix and others added 2 commits July 30, 2026 16:05
@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Jul 31, 2026
@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>
Co-authored-by: Thelmachido <thelmachido@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: noisysocks <noisysocks@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 commented Jul 31, 2026 •

Copy link
Copy Markdown

Size Change: +19 B (0%)

Total Size: 7.76 MB

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

compressed-size-action

ellatrix and others added 3 commits July 30, 2026 19:24
…inner-blocks

# Conflicts:
#	test/e2e/specs/editor/various/copy-cut-paste.spec.js
@ellatrix ellatrix mentioned this pull request Aug 11, 2026
27 of 81 tasks

This branch has not been deployed

No deployments
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List block: preserve original markup when copy/paste for nested UL/LI structures

1 participant