Fix: handle Delete merging with following paragraph after nested list…#77261
Fix: handle Delete merging with following paragraph after nested list…#77261yyppsk wants to merge 6 commits intoWordPress:trunkfrom
Conversation
|
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 If 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. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @yyppsk! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
mikachan
left a comment
There was a problem hiding this comment.
Thanks for working on this!
These changes look good, and they're testing well for me. I see you added some tests, but then reverted them. I think testing these changes would be a good idea, so I'd suggest adding some tests back before we merge this.
I’ve also included the reverted and improved tests in the new commit.t @mikachan . |
mikachan
left a comment
There was a problem hiding this comment.
Thanks for the recent changes! I've spotted one other potential change in the test file.
|
Thanks for the work here, @yyppsk! There is one more edge case that this fix reveals, though. I wonder if we should fix it in this same PR or separately:
delete-into-sibling-list.mov |
What?
Closes #77245
Fixes forward Delete at the end of a nested list item so it correctly merges the following block (e.g. a paragraph) into the list.
Why?
When pressing
Deleteat the end of a nested list item, nothing happens if the next block is outside the list hierarchy (e.g. a paragraph after the list). This is becausegetNextIdonly searches within the list's own tree and returnsundefinedfor nested items that are the last at every level, causing the code to fall through toonMerge( forward ), which itself has no effect since the list-item is not top-level.Top-level list items already merge correctly with following blocks; only nested items are broken.
How?
Added a new helper
getNextOuterBlockClientIdinuseMergethat, whengetNextIdreturns nothing, walks up through ancestor list-items and checks whether any ancestor list has a next sibling block. If one is found,mergeBlocksis called between the ancestor list and that following block, which uses the existing__experimentalOnMergemerge path oncore/listto absorb the block as new list items.The fix is intentionally not guarded to only
core/paragraph, themergeBlockscodepath already handles non-convertible block types gracefully (it simply selects the first block without modifying anything), and top-level items already merge with any block type, so nested items should behave consistently.Testing Instructions
Delete.Testing Instructions for Keyboard
Same as above.
Screenshots or screencast
Screen.Recording.2026-04-13.at.2.59.15.PM.mov
Screen.Recording.2026-04-13.at.2.55.36.PM.mov
Use of AI Tools
Claude was used to review the patch, evaluate correctness. All code was reviewed manually.