[lexical-list] Bug Fix: keep the list's dir attribute in exported HTML - #9001
Closed
LeSingh1 wants to merge 1 commit into
Closed
[lexical-list] Bug Fix: keep the list's dir attribute in exported HTML#9001LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
## Description
Both list importers read `dir` off the `<ol>`/`<ul>`: `$convertListNode`
calls `$setDirectionFromDOM(node, domNode)`, and so does `ListRule` in the
`DOMImportExtension` pipeline. Nothing writes it back out.
`ElementNode.exportDOM` is what normally emits `element.dir` from
`getDirection()`, but `ListNode.exportDOM` builds its element with
`createDOM` and returns it directly without going through `super.exportDOM`,
so the direction is dropped. `ListItemNode.exportDOM`, right next to it, does
emit `element.dir`, so a copied RTL list currently exports as
`<ul><li dir="rtl">…</li></ul>` — the item keeps its direction and the list
that owns it silently loses it, and re-importing that HTML no longer produces
the node it came from.
This emits `dir` from `ListNode.exportDOM` when the node has an explicit
direction, matching `ListItemNode` and what the importers expect to read. A
node with no explicit direction is unaffected, so existing output is
unchanged.
## Test plan
`npx vitest run packages/lexical-list/src/__tests__/unit/LexicalListNode.test.ts`
### Before
```
FAIL |unit| packages/lexical-list/src/__tests__/unit/LexicalListNode.test.ts > LexicalListNode tests > ListNode.exportDOM() round-trips the dir attribute
AssertionError: expected '<ul><li value="1" dir="rtl"><span sty…' to contain '<ul dir="rtl">'
Expected: "<ul dir="rtl">"
Received: "<ul><li value="1" dir="rtl"><span style="white-space: pre-wrap;">שלום</span></li></ul>"
Test Files 1 failed (1)
Tests 1 failed | 18 passed (19)
```
### After
```
Test Files 1 passed (1)
Tests 19 passed (19)
```
`npx vitest run packages/lexical-list packages/lexical-html packages/lexical-clipboard packages/lexical-markdown` is also green (25 files, 667 tests).
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 9, 2026 05:00
|
@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
Both list importers read
diroff the<ol>/<ul>:$convertListNodecalls
$setDirectionFromDOM(node, domNode), and so doesListRulein theDOMImportExtensionpipeline. Nothing writes it back out.ElementNode.exportDOMis what normally emitselement.dirfromgetDirection(), butListNode.exportDOMbuilds its element withcreateDOMand returns it directly without going throughsuper.exportDOM,so the direction is dropped.
ListItemNode.exportDOM, right next to it, doesemit
element.dir, so a copied RTL list currently exports as<ul><li dir="rtl">…</li></ul>— the item keeps its direction and the listthat owns it silently loses it, and re-importing that HTML no longer produces
the node it came from.
This emits
dirfromListNode.exportDOMwhen the node has an explicitdirection, matching
ListItemNodeand what the importers expect to read. Anode with no explicit direction is unaffected, so existing output is
unchanged.
Test plan
npx vitest run packages/lexical-list/src/__tests__/unit/LexicalListNode.test.tsBefore
After
npx vitest run packages/lexical-list packages/lexical-html packages/lexical-clipboard packages/lexical-markdownis also green (25 files, 667 tests).