[lexical-list] Bug Fix: continue split-list numbering from the item's value, not its index - #8913
Merged
Conversation
… value, not its index
## Description
With `registerList(editor, {restoreNumbering: true})`, pressing Enter on an empty
list item splits the list and the tail list is given a `start` so that numbering
continues where it left off. `$getNewListStart` computed that start as
`list.getStart() + listItem.getIndexWithinParent()`.
Index is not the same as the rendered number. `updateChildrenListItemValue`
deliberately does not advance the counter for a list item that only wraps a
nested list (`if (!$isListNode(child.getFirstChild())) value++`), because such an
item renders no marker of its own. Every nested sublist before the split point
therefore pushes the computed start one number too high, and the split-off list
skips numbers:
```
1. A
• A.1 <- wrapper <li>, renders no number
2. B
3. <empty item, caret here, press Enter>
4. C
```
Before: the tail list starts at 4, so the document reads 1, 2, paragraph, 4, 5 —
the number 3 disappears. Expected (and what the flat case already does): the tail
list starts at 3.
`ListItemNode.getValue()` is exactly the rendered number that
`updateChildrenListItemValue` maintains, so using it fixes the nested case and is
identical to the old expression for a flat list.
## Test plan
### Before
New unit test in `LexicalListItemNode.test.ts` fails on `main`:
```
FAIL Option Enabled: Preserves numbering when a nested sublist precedes the split
AssertionError: expected 4 to be 3 // Object.is equality
- Expected
+ Received
- 3
+ 4
```
### After
`pnpm exec vitest --project unit packages/lexical-list` passes (120 tests).
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 4, 2026 03:43
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
approved these changes
Aug 5, 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.
Description
$getNewListStartcomputes the split-off list'sstartfrom the item's position:Index is not the rendered number.
updateChildrenListItemValuedeliberately does not advance the counter for a list item that only wraps a nested list, so index and value diverge as soon as the list contains a sublist. Every nested sublist before the split point inflates the computed start by one.Pressing Enter on an empty item in a list with a preceding sublist therefore produces
1, 2, <paragraph>, 4, 5— the number 3 is skipped.Returning
listItem.getValue()uses the number the split point was actually rendered with. That matches the semantics the existing flat-case test already pins down: the tail list continues at the removed item's number.Introduced in #8092;
packages/lexical-list/src/utils.tshas not been touched since.Test plan
Before
New test in
LexicalListItemNode.test.tsfails onmain:After
Passes. Full
packages/lexical-listsuite: 9 files, 120 tests passed. The existing flat-list numbering tests are unchanged.eslint,prettierandtsc --noEmitclean.