Repository navigation
fix(muya): keep list item non-empty on Enter in empty first paragraph (#4644) - #4660
Merged
Merged
Conversation
…#4644) Pressing Enter on the empty first paragraph of a loose list item (one that holds multiple paragraphs) moved every paragraph from the caret's index into a new sibling list item. When the caret was on the first paragraph (index 0), this emptied the original list item, leaving a `list-item` with zero children. A childless list item has no content descendant, so `previousContentInContext`/`nextContentInContext` return null when arrow navigation tries to cross it — Up arrow then stopped moving the caret up a line, the symptom reported in #4644. Split from the next paragraph when the caret is on the first one, mirroring the plain-paragraph "Enter at offset 0" behaviour, so the original list item keeps its empty first paragraph and stays valid. Adds a unit test for the engine invariant and an e2e regression test driving the exact reported keystroke sequence. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This was referenced Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4644 — after a series of list edits, the Up arrow stops moving the caret up a line and the user has to click instead.
Root cause
ParagraphContent._enterInListItemhandles pressing Enter on an empty paragraph that is not the only child of a loose list item by moving every paragraph from the caret's index to the end of the item into a new sibling list item:When the caret sits on the first paragraph (
offset === 0), this moves all paragraphs out and leaves the originallist-itemwithchildren: []. A childless list item has no content descendant, sopreviousContentInContext/nextContentInContextreturnnullwhen arrow navigation tries to step over it —Content.arrowHandlerthenpreventDefaults the Up arrow but finds no previous block to land on, so the caret cannot move up.The reported sequence (
* ␣ A ⏎ B ↑ ⏎ ⌫ ↑ ⏎ ⏎ ⏎) walks the document into exactly this state.Fix
When the empty paragraph is the first child, split from the next paragraph instead, keeping the empty first paragraph in the original item. This mirrors the established plain-paragraph "Enter at offset 0" behaviour and keeps every list item valid (≥1 content child).
Tests
enterListItemEmptyFirst.spec.ts) — pins the engine invariant: Enter on the empty first paragraph of a multi-paragraph list item never yields a childless list item, and splits into two non-empty items.list-nav-4644.spec.ts) — drives the exact reported keystroke sequence in a real browser and asserts (1) no empty list item remains and (2) Up arrow still moves the caret to an earlier content block. Both tests were confirmed to fail on the unfixed source and pass with the fix.🤖 Generated with Claude Code