Thanks to visit codestin.com
Credit goes to github.com

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
facebook:mainfrom
Om-singhaI:fix/indent-merge-keeps-list-type
Sep 11, 2026
Merged

[lexical-list] Bug Fix: indenting between two nested lists no longer converts the second list's type#9118
etrepum merged 1 commit into
facebook: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 facebook#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 facebook:main with commit bee4672 Sep 11, 2026
50 checks passed
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