[lexical-markdown] Bug Fix: Fix nested mixed-type list structure during markdown import#8283
Conversation
…ng markdown import
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Review: Fix Nested Mixed-Type List Structure During Markdown ImportReviewed by: Navi (AI review assistant for @potatowagon) SummaryFixes markdown import to correctly handle nested lists of different types (e.g., unordered list with ordered sub-items, or ordered list with bullet sub-items). Previously, indented items of a different list type would be incorrectly merged into the parent list rather than creating a properly nested sub-list. What I Verified
Concern
Verdict✅ Safe to approve — well-tested fix for a real formatting bug. The logic correctly handles the restructuring needed for mixed-type nested lists. |
potatowagon
left a comment
There was a problem hiding this comment.
Review — Fix Nested Mixed-Type List Structure During Markdown Import
Assessment: Looks good to land ✅
What I verified:
-
Bug fix logic: When importing markdown with nested lists of different types (e.g., bullet under ordered, or ordered under bullet), the previous code appended all items to the same parent list regardless of type. This fix detects type mismatches and creates a properly-typed sub-list, wrapping it in a new ListItemNode and inserting it correctly in the hierarchy.
-
Key logic check: The indent-based path (
indent > 0 && $isListNode(previousNode)) now correctly appends to the previous list node. When a type mismatch is detected post-indentation, the code removes the item from the wrong-type parent, creates a new list of the correct type, wraps it in a ListItemNode, and inserts after the parent wrapper. Empty parent lists are cleaned up. -
Test coverage: 4 new test cases covering: bullet→ordered nesting, ordered→bullet nesting, 3-level mixed nesting (ul→ol→ul), and mixed sublists under the same parent.
-
CI status: Full CI suite green (39 checks pass).
-
Risk: Medium — modifies the list import path which is sensitive to edge cases. However, the tests demonstrate correct behavior for the tricky nested cases, and the full e2e suite passing validates no regressions in existing list behavior.
— via Navi on behalf of potatowagon
Description
Importing markdown with nested lists of different types (e.g. bullet containing ordered) flattened them into separate top-level lists.
listReplaceonly merged items into an adjacent list when types matched, so indented items of a different type couldn't merge. Fixed by allowing the merge when indented regardless of type, then correcting the nested list type aftersetIndent().Closes #7938
Before
Lexical.Playground.12.mp4
After
Lexical.Playground.13.mp4