Skip to content

[lexical-list] Bug Fix: indenting between two nested lists no longer converts the second list's type - #9118

Merged
etrepum merged 1 commit into
meta:mainfrom
Om-singhaI:fix/indent-merge-keeps-list-type
Sep 11, 2026
Merged

etrepum merged 1 commit into
meta:mainfrom
Om-singhaI:fix/indent-merge-keeps-list-type

Conversation

@Om-singhaI

Copy link
Copy Markdown
Contributor

Description

Pressing Tab on a list item between two nested sublists of different types silently rewrites the second sublist. Tab routes INDENT_CONTENT_COMMAND to ListItemNode.setIndent, which calls $handleIndent. The item indents into the sublist above it, and the sublist below is emptied into it, so a nested <ol> and every item in it come back as bullets. A check sublist loses more: updateChildrenListItemValue clears checked outside a check list.

The caret is on middle, between a nested bullet sublist and a nested numbered sublist. After Tab on main the numbered list is gone and its items are bullets:

list (bullet)
  listitem > list (bullet)
    listitem "bullet child"
    listitem "middle"
    listitem "number one"
    listitem "number two"

After Tab with this change, the item still indents and the numbered list keeps its type and children:

list (bullet)
  listitem > list (bullet)
    listitem "bullet child"
    listitem "middle"
  listitem > list (number)
    listitem "number one"
    listitem "number two"

mergeNextSiblingListIfSameType has long stated this rule at the top level: "<ul> will merge with <ul>, but NOT <ul> with <ol>." #9050 carried it to two nested merge sites, mergeLists and ListItemNode.remove, the latter handling this very shape and joining the surrounding sublists only when getListType() matches. The branch of $handleIndent with a nested sublist on both sides merges the same way and was missed.

This change guards that merge on the same getListType() equality, so a sublist of another type stays where it is instead of being appended and removed.

Test plan

Three tests in the $handleIndent block of packages/lexical-list/src/__tests__/unit/formatList.test.ts cover bullet then number, number then bullet, and bullet then check, the last asserting checked survives. A fourth pins the same type case.

Before

The three new tests against the previous formatList.ts:

 × does not merge the surrounding sublists of a different listType
 × does not merge the surrounding sublists of a different listType, the other way round
 × keeps the checked state of a following check sublist
AssertionError: expected 'bullet' to be 'number' // Object.is equality
      Tests  3 failed | 23 passed (26)

After

26 passed. All 15 unit files in packages/lexical-list pass, 146 tests, plus LexicalListPlugin.test.tsx. eslint and prettier are clean. Browser and e2e not run.

…converts the second list's type

$handleIndent merged the sublist after an indented item into the one
before it without comparing list types, so Tab between a nested bullet
list and a nested numbered list turned the numbers into bullets.
I guarded it on getListType(), as mergeNextSiblingListIfSameType does
at the top level and meta#9050 did for mergeLists and ListItemNode.remove.
@vercel

vercel Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Sep 5, 2026 7:19pm UTC
lexical-playground Ready Ready Preview Sep 5, 2026 7:19pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 5, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Sep 9, 2026
@etrepum
etrepum added this pull request to the merge queue Sep 11, 2026
Merged via the queue into meta:main with commit bee4672 Sep 11, 2026
50 checks passed
@etrepum etrepum mentioned this pull request Sep 17, 2026
etrepum pushed a commit to etrepum/lexical that referenced this pull request Sep 28, 2026
## Description

Sync with main (101 commits, through e22c50b). Conflict resolutions and
semantic reconciliation with the semantic list nesting work:

- Markdown list import (meta#8283): main's CommonMark-style column nesting,
  `precedingBlock` handling of loose lists and `$retypeNestedList` are
  adopted in `listReplace`, with the semantic mode's bullet/check
  cross-type merge layered on: `$mergeable` decides continuation for the
  next/preceding list (reducing to main's same-type rule outside the
  semantic import), `$retypeNestedList` leaves an item in a mergeable
  nested list instead of splitting it out, and `$reconcileMixedList` runs
  against the list the row finally landed in. Existing semantic-vs-default
  equivalence tests that encoded the old fixed-4-space reading of
  `- a\n  - b\n    - c` are updated: under column nesting "b" owns "c", so
  outdenting/converting it is the documented case where the modes differ
  (the semantic result keeps the subtree together) and is now asserted
  per mode.
- Node JSON schemas (meta#8602): ListItemNode / ListNode adopt main's
  `nodeSchema` + generated JSON (`afterCloneFrom`/`exportJSON`/
  `updateFromJSON` removed in favor of the schema); the semantic-nesting
  imports, `createDOM(config, editor?)` and the Flow `getListItemPlain`/
  `setListItemPlain` declarations are kept alongside. The legacy
  `MarkdownCriteria` code main deleted from `@lexical/markdown`'s utils
  (including this branch's `$processNestedLists`) goes with it.
- `$handleIndent` between two wrappers (meta#9118): main's same-listType guard
  is already `$collapseWrapperPair`'s policy; kept ours.

## Test plan

### After

```
pnpm vitest --project unit run packages/lexical-list packages/lexical-markdown packages/lexical-mdast — passes
pnpm vitest --project browser run dev-examples/mdast-editor packages/lexical-list — passes
pnpm run ci-check — passes
```

Co-Authored-By: Claude Fable 5.1 <[email protected]>

This branch was successfully deployed

2 active deployments
Preview – lexical — 4defbb47 Deployed Sep 5, 2026 by vercel[bot]
Preview – lexical-playground — 4defbb47 Deployed Sep 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants