Skip to content

[lexical-list] Bug Fix: don't merge adjacent nested lists of a different listType - #8925

Open
LeSingh1 wants to merge 1 commit into
facebook:mainfrom
LeSingh1:fix/nested-list-merge-listtype
Open

[lexical-list] Bug Fix: don't merge adjacent nested lists of a different listType#8925
LeSingh1 wants to merge 1 commit into
facebook:mainfrom
LeSingh1:fix/nested-list-merge-listtype

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

mergeNextSiblingListIfSameType() documents that a <ul> merges with a <ul> but not with an <ol>. That check is only applied to the two top-level lists. The recursive step inside mergeLists(), and the same merge in ListItemNode.remove(), join the sublists at the boundary without looking at listType, so the second sublist loses its type and its items are absorbed into the first.

Two reachable paths:

  • Deleting a list item between a nested <ul> and a nested <ol> turns the <ol> into bullets.
  • The ListNode $transform merges two adjacent <ul>s whose boundary sublists differ, with the same result.

Both sites now compare listType before merging. When they differ the sublists stay as separate list items; nothing is dropped.

Test plan

Before

Two new unit tests fail on main — the <ol> is replaced by a second <li> inside the <ul>:

-     </ul>
-   </li>
-   <li value="1">
-     <ol>
-       <li value="1"><span data-lexical-text="true">B</span></li>
+       <li value="2"><span data-lexical-text="true">B</span></li>
-     </ol>
+     </ul>

After

Both pass. pnpm run test-unit green (227 files, 4940 passed).

…ent listType

mergeNextSiblingListIfSameType() only compares listType at the top level.
Its recursive helper mergeLists(), and ListItemNode.remove(), merged the
sublists at the join point unconditionally, so a nested <ol> next to a
nested <ul> lost its type. Compare listType in both places.
@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Aug 4, 2026 8:13pm
lexical-playground Ready Ready Preview Aug 4, 2026 8:13pm

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 Aug 4, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Aug 5, 2026
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