Repository navigation
Conversation
…ion when exporting HTML ## Description Slots are shadow-root isolated, so a selection wholly inside a slot subtree never includes its host. A walk over the root's children therefore misses the selected nodes and exports nothing. `$generateDOMFromNodes` handles that by redirecting the walk through the selection's slot frame — but only for a `RangeSelection`: ```js const slotFrame = $isRangeSelection(selection) ? $getSlotFrame(selection.anchor.getNode()) : null; ``` Its sibling `$generateJSONFromSelectedNodes` in `@lexical/clipboard` handles both selection types, and says why in a comment that applies verbatim here: > NodeSelection participates here too — a click that selects a decorator > nested in a slot needs the same frame redirect, otherwise its export > pipeline silently produces an empty clipboard. The fix for meta#8712 (`2f2bc97c1`) only updated `@lexical/clipboard`; `$generateDOMFromNodes` was never brought along. `$isNodeSelection` is already imported in this file, so the omission is not a missing import. The result is a split between the two clipboard channels: selecting a node nested in a slot and copying puts a correct `application/x-lexical-editor` payload on the clipboard and an **empty** `text/html` one, so pasting into any other application yields nothing. The existing regression test for meta#8712 (`SlotClipboardExport.test.ts`) only asserts the JSON channel, which is why the gap was not caught — the RangeSelection test beside it deliberately asserts "on both channels". This mirrors the clipboard implementation exactly, including anchoring on the first selected node for a `NodeSelection`. ## Test plan New unit test `packages/lexical-html/src/__tests__/unit/SlotNodeSelectionExport.test.ts`. The RangeSelection case is included as a control: it passes before and after, which is what pins the asymmetry to the selection type. ### Before ``` $ npx vitest run packages/lexical-html/src/__tests__/unit/SlotNodeSelectionExport.test.ts × a NodeSelection inside a slot exports the node, not empty HTML 10ms AssertionError: expected '' to contain 'SlotNodeTarget' Tests 1 failed | 1 passed (2) ``` ### After ``` $ npx vitest run packages/lexical-html/src/__tests__/unit/SlotNodeSelectionExport.test.ts Test Files 1 passed (1) Tests 2 passed (2) $ npx vitest run packages/lexical-html packages/lexical-clipboard Test Files 14 passed (14) Tests 114 passed (114) ```
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 9, 2026 05:16
|
@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
Slots are shadow-root isolated, so a selection wholly inside a slot subtree
never includes its host. A walk over the root's children therefore misses the
selected nodes and exports nothing.
$generateDOMFromNodeshandles that byredirecting the walk through the selection's slot frame — but only for a
RangeSelection:Its sibling
$generateJSONFromSelectedNodesin@lexical/clipboardhandlesboth selection types, and says why in a comment that applies verbatim here:
The fix for #8712 (
2f2bc97c1) only updated@lexical/clipboard;$generateDOMFromNodeswas never brought along.$isNodeSelectionis alreadyimported in this file, so the omission is not a missing import.
The result is a split between the two clipboard channels: selecting a node
nested in a slot and copying puts a correct
application/x-lexical-editorpayload on the clipboard and an empty
text/htmlone, so pasting into anyother application yields nothing. The existing regression test for #8712
(
SlotClipboardExport.test.ts) only asserts the JSON channel, which is why thegap was not caught — the RangeSelection test beside it deliberately asserts
"on both channels".
This mirrors the clipboard implementation exactly, including anchoring on the
first selected node for a
NodeSelection.Test plan
New unit test
packages/lexical-html/src/__tests__/unit/SlotNodeSelectionExport.test.ts.The RangeSelection case is included as a control: it passes before and after,
which is what pins the asymmetry to the selection type.
Before
After