Repository navigation
Conversation
…etween list items ## Description `ListItemNode.insertAfter` splits its list when the node being inserted is not a `ListItemNode` — that is how a page break, horizontal rule, image, or any other block ends up between two items. The trailing items are moved into `$copyNode(listNode)`, which carries the *original* list's `start`, so the `ListNode` `$transform` renumbers them from that start and the list visibly restarts at 1 after the inserted block. `$getNewListStart` already exists for exactly this: it is the helper `$handleListInsertParagraph` uses to continue the numbering across a split, and it returns the number the split point was rendered with (the item's value, not its index, so nested-list wrapper items do not skew it). This applies it to the `insertAfter` split, using the first item that moves into the new list. It is scoped to `listType === 'number'`, the only list type where `start` is meaningful, so bullet and check lists keep the `start` they copy today. Refs meta#7032 ## Test plan `npx vitest run packages/lexical-list/src/__tests__/unit/Issue7032Repro.test.ts` (The natural test file, `LexicalListItemNode.test.ts`, is already being edited by an open PR, so the repro lives in its own file.) ### Before ``` ❯ |unit| packages/lexical-list/src/__tests__/unit/Issue7032Repro.test.ts (3 tests | 2 failed) 14ms × inserting a block between list items continues the numbering 11ms × a list that does not start at 1 continues from the split point 1ms FAIL ... > inserting a block between list items continues the numbering AssertionError: expected 1 to be 2 // Object.is equality - Expected + Received - 2 + 1 FAIL ... > a list that does not start at 1 continues from the split point AssertionError: expected 5 to be 7 // Object.is equality - Expected + Received - 7 + 5 ``` ### After ``` Test Files 1 passed (1) Tests 3 passed (3) ``` Also green: - `npx vitest run packages/lexical-list` — 11 files, 128 tests - `npx vitest run packages/lexical-markdown packages/lexical-mdast packages/lexical-react packages/lexical-clipboard` — 41 files, 798 tests - `E2E_BROWSER=chromium npx playwright test --project=chromium List.spec.mjs` — 36 passed - `E2E_BROWSER=chromium npx playwright test --project=chromium HorizontalRule.spec.mjs` — 15 passed (this is the suite that exercises inserting a rule inside a list) Only chromium was exercised locally for the e2e runs.
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 9, 2026 05:28
|
@LeSingh1 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
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.
Description
ListItemNode.insertAftersplits its list when the node being inserted is nota
ListItemNode— that is how a page break, horizontal rule, image, or anyother block ends up between two items. The trailing items are moved into
$copyNode(listNode), which carries the original list'sstart, so theListNode$transformrenumbers them from that start and the list visiblyrestarts at 1 after the inserted block.
$getNewListStartalready exists for exactly this: it is the helper$handleListInsertParagraphuses to continue the numbering across a split, andit returns the number the split point was rendered with (the item's value, not
its index, so nested-list wrapper items do not skew it).
This applies it to the
insertAftersplit, using the first item that movesinto the new list. It is scoped to
listType === 'number', the only list typewhere
startis meaningful, so bullet and check lists keep thestarttheycopy today.
Refs #7032
Test plan
npx vitest run packages/lexical-list/src/__tests__/unit/Issue7032Repro.test.ts(The natural test file,
LexicalListItemNode.test.ts, is already being editedby an open PR, so the repro lives in its own file.)
Before
After
Also green:
npx vitest run packages/lexical-list— 11 files, 128 testsnpx vitest run packages/lexical-markdown packages/lexical-mdast packages/lexical-react packages/lexical-clipboard— 41 files, 798 testsE2E_BROWSER=chromium npx playwright test --project=chromium List.spec.mjs— 36 passedE2E_BROWSER=chromium npx playwright test --project=chromium HorizontalRule.spec.mjs— 15 passed(this is the suite that exercises inserting a rule inside a list)
Only chromium was exercised locally for the e2e runs.