Skip to content

[lexical-core] Bug fix: support dom selection for elements with slots#8159

Merged
etrepum merged 2 commits intomainfrom
slot-selection
Feb 20, 2026
Merged

[lexical-core] Bug fix: support dom selection for elements with slots#8159
etrepum merged 2 commits intomainfrom
slot-selection

Conversation

@fantactuka
Copy link
Copy Markdown
Collaborator

Description

Dom selection didn't adjust for element slots. Can reproduce it by having element node with slot, and then trying to select its direct children:

// Custom element node

class CustomElementNode extends ElementNode {
  getDOMSlot(element: HTMLElement): ElementDOMSlot<HTMLElement> {
    return super
      .getDOMSlot(element)
      .withElement(element.lastElementChild as HTMLElement);
  }
}

// Some plugin
customElementNode.select(0, customElementNode.getChildrenSize())

Test plan

I've updated LayoutItemNode createDom to render extra DOM children, added getDOMSlot as mentioned above and had a UI trigger to select all its children:

pnpm run test-unit packages/lexical/src/nodes/__tests__/unit/LexicalElementNode.test.tsx
 Test Files  1 passed (1)
      Tests  40 passed (40)
   Start at  15:43:21
   Duration  1.43s (transform 402ms, setup 18ms, collect 656ms, tests 67ms, environment 365ms, prepare 71ms)

Before

CleanShot.2026-02-20.at.15.25.18.mp4

After

CleanShot.2026-02-20.at.15.24.18.mp4

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 20, 2026

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Feb 20, 2026 2:45pm
lexical-playground Ready Ready Preview, Comment Feb 20, 2026 2:45pm

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 Feb 20, 2026
@fantactuka fantactuka self-assigned this Feb 20, 2026
@fantactuka fantactuka changed the title Slot selection [lexical-core] Fix: support dom selection for elements with slots Feb 20, 2026
@fantactuka fantactuka changed the title [lexical-core] Fix: support dom selection for elements with slots [lexical-core] Bug fix: support dom selection for elements with slots Feb 20, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Feb 20, 2026
Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, didn't come up with the table use case. Would be good to add something else that uses DOMSlot so that we can make it ready to be a public API

@etrepum etrepum added this pull request to the merge queue Feb 20, 2026
Merged via the queue into main with commit ee59864 Feb 20, 2026
43 checks passed
@etrepum etrepum mentioned this pull request Feb 25, 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