Repository navigation
List: Keep nested lists when pasting a copied list item into a list - #84115
im3dabasia wants to merge 9 commits into
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +30 B (0%) Total Size: 9.06 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome 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. Regression: updating a specific option will only change its value and will not corrupt others in
|
There was a problem hiding this comment.
🟡 Changes recommended
Pasting into an item that already has children can silently delete its existing nested list.
1 open finding
What changed in this PR
Preserves nested list items during copy/paste operations.
Changes:
- Retains inner blocks when merging pasted list items.
- Handles pasting into empty list items.
- Adds end-to-end coverage and a changelog entry.
| File | Description |
|---|---|
packages/block-editor/src/store/actions.js |
Preserves inner blocks during merges. |
packages/block-editor/src/components/writing-flow/use-clipboard-handler.js |
Converts invalid replacement blocks before pasting. |
test/e2e/specs/editor/blocks/list.spec.js |
Tests nested-list copy, cut, and paste. |
packages/block-editor/CHANGELOG.md |
Documents the fix. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
| @@ -1228,6 +1228,9 @@ export const __unstableSplitSelection = | |||
| ...head.attributes, | |||
| ...headType.merge( head.attributes, first.attributes ), | |||
| }, | |||
| // Keep the merged block's inner blocks, like the nested list | |||
| // of a pasted list item. | |||
| innerBlocks: [ ...head.innerBlocks, ...first.innerBlocks ], | |||
|
cc @ellatrix this feels like a good one to review. |
|
Thanks for the PR, @im3dabasia! The empty list item bug has the same root cause as #82980 (Preformatted and Poetry, fix proposed in #83552). The "entirely selected" branch from #80994 runs before the I think we can fix both here by moving that branch to the end of the handler, instead of adding the // Pasting over an entirely selected block replaces it, the
// equivalent of pasting into an empty block.
if (
! hasMultiSelection() &&
isBlockEntirelySelected(
event.target.ownerDocument,
firstSelectedClientId
)
) {
replaceBlocks(
selectedBlockClientIds,
newBlocks,
newBlocks.length - 1,
-1
);
} else {
__unstableSplitSelection( newBlocks );
}
event.preventDefault();I haven't tested this. If it works, could you also add an e2e test for pasting multi-line text into an empty Preformatted block? It can go in |
|
@im3dabasia, I merged #83552, but I think my suggestion is still valid. Give it a try when you have time. |
|
@im3dabasia, no rush. Just wanted to keep you updated, hence the pings :) |
Thanks @Mamaduka, done. Moving the check to the end works for the empty list item. Attaching some screencast. Screen.Recording.2026-10-15.at.3.42.42.PM.mov |



What?
Closes #71317
Pasting a copied list item into another list item now keeps its nested list.
Why?
Copying an item with sub-items works since #80462. Pasting it into a list still fails in two ways.
1. The nested list is dropped when pasting into an item with text
2. Nothing is pasted into an empty list item
How?
Pasting into the middle of an item's text still joins the text, e.g. "item 1.1item 3". This is the existing behaviour for every block type that can merge, like paragraphs, and is unchanged here. This PR only stops the nested list from being lost.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Screen.Recording.2026-10-06.at.5.51.19.PM.mov
temp-bug-1.mov
Screen.Recording.2026-10-06.at.5.51.50.PM.mov
temp-bug-2.mov
Use of AI Tools
Authored with Claude Code under my direction; I reviewed the changes and tested them manually.