Repository navigation
Conversation
… state
## Description
`$createListOrMerge` copies a block's element state onto the list item it
creates when a list is inserted:
```ts
listItem.setFormat(node.getFormatType());
listItem.setIndent(node.getIndent());
```
`$removeList` is the inverse operation and does not do the reverse. It builds
each replacement paragraph from the *selection's* text style and format only,
so the item's own `format` (alignment), `indent`, `direction` and `style` are
dropped. Turning a centred, indented paragraph into a list and back loses the
centring and the indent; a nested item comes back flush left instead of one
level in; an RTL item comes back LTR even though both importers read `dir` off
the `<li>` and `ListItemNode.exportDOM` writes it.
This carries those four onto the paragraph that stands in for the item.
`indent` in particular is derived from the nesting for an attached list item,
so it is the only thing that can reproduce a nested item's rendering once the
list is gone.
## Test plan
`npx vitest run packages/lexical-list/src/__tests__/unit/RemoveListKeepsItemState.test.ts`
(The natural test file, `formatList.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/RemoveListKeepsItemState.test.ts (2 tests | 2 failed) 17ms
× the paragraphs keep the items format, indent, direction and style 14ms
× a formatted paragraph round-trips through a list 2ms
FAIL ... > the paragraphs keep the items format, indent, direction and style
AssertionError: expected [ { direction: null, …(4) }, …(1) ] to deeply equal [ { direction: 'rtl', …(4) }, …(1) ]
- Expected
+ Received
[
{
- "direction": "rtl",
- "format": "center",
+ "direction": null,
+ "format": "",
"indent": 0,
- "style": "color: red;",
+ "style": "",
"text": "a",
},
{
"direction": null,
"format": "",
- "indent": 1,
+ "indent": 0,
"style": "",
"text": "b",
},
]
```
### After
```
Test Files 1 passed (1)
Tests 2 passed (2)
```
Also green:
- `npx vitest run packages/lexical-list packages/lexical-markdown packages/lexical-mdast packages/lexical-react` — 49 files, 902 tests
- `E2E_BROWSER=chromium npx playwright test --project=chromium List.spec.mjs` — 36 passed
Only chromium was exercised locally for the e2e run.
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 9, 2026 05:49
|
@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
$createListOrMergecopies a block's element state onto the list item itcreates when a list is inserted:
$removeListis the inverse operation and does not do the reverse. It buildseach replacement paragraph from the selection's text style and format only,
so the item's own
format(alignment),indent,directionandstylearedropped. Turning a centred, indented paragraph into a list and back loses the
centring and the indent; a nested item comes back flush left instead of one
level in; an RTL item comes back LTR even though both importers read
diroffthe
<li>andListItemNode.exportDOMwrites it.This carries those four onto the paragraph that stands in for the item.
indentin particular is derived from the nesting for an attached list item,so it is the only thing that can reproduce a nested item's rendering once the
list is gone.
Test plan
npx vitest run packages/lexical-list/src/__tests__/unit/RemoveListKeepsItemState.test.ts(The natural test file,
formatList.test.ts, is already being edited by anopen PR, so the repro lives in its own file.)
Before
After
Also green:
npx vitest run packages/lexical-list packages/lexical-markdown packages/lexical-mdast packages/lexical-react— 49 files, 902 testsE2E_BROWSER=chromium npx playwright test --project=chromium List.spec.mjs— 36 passedOnly chromium was exercised locally for the e2e run.