Repository navigation
[lexical-table] Bug Fix: Import the dir attribute in table importDOM - #8914
Merged
Merged
Conversation
ElementNode.exportDOM writes the explicit `dir` attribute for every element node, but the @lexical/table converters never read it back, so an explicit direction on a table, row, or cell is dropped on import. meta#8412 fixed this for paragraph, heading, quote, list, and list item; tables were missed. Apply $setDirectionFromDOM in $convertTableElement, $convertTableRowElement, and $convertTableCellNodeElement so the attribute round trips through $generateHtmlFromNodes / $generateNodesFromDOM and is honored when pasting HTML that specifies a direction.
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 4, 2026 05:37
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
approved these changes
Aug 5, 2026
Merged
This branch was successfully deployed
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
ElementNode.exportDOMwrites the explicitdirattribute for every element node, but the@lexical/tableDOM converters never read it back. An explicit direction on aTableNode,TableRowNode, orTableCellNodetherefore survivesexportJSON/importJSONbut is silently dropped through$generateHtmlFromNodes→$generateNodesFromDOM, and a pasted<table dir="rtl">is ignored.#8412 fixed this for
ParagraphNode,HeadingNode,QuoteNode,ListNodeandListItemNode, and added the shared$setDirectionFromDOMhelper. Tables were missed. This applies the same helper in$convertTableElement,$convertTableRowElementand$convertTableCellNodeElement.One intentional consequence a reviewer should look at, matching the snapshot updates #8412 made across its e2e specs: the existing
Copy table from an external source like gdoc with formattingfixture carriesdir="ltr"on its<table>, so that table is now explicitlyltrrather than bidi-auto, and its rows no longer auto-detect (a parent with an explicit__dirsuppressesdir="auto"on descendants). The test expectation is updated accordingly, with an inline comment. If you'd rather tables keep auto-detecting for external pastes, that's the point to push back on.I deliberately left table indent alone even though
data-lexical-indenthas the same asymmetry: all three table node types declarecanIndent(): false, so indent isn't user-reachable there, and wiring it up would newly interpretpadding-inline-starton arbitrary pasted<table>/<td>as indent on nodes that explicitly opt out.Test plan
Before
New
importDOM preserves the dir attributeblock inLexicalTableNode.test.tsx, onmain:After
Full
pnpm run test-unit: 4940 passed. The only failures are the two pre-existing 5000mstestTimeoutflakes inMdastTextRuns.test.tsandFastPathCrossParent.test.ts— timeouts, not assertion failures, in files this PR doesn't touch.tsc --noEmit,eslintandprettierall clean.