Repository navigation
[lexical] Bug Fix: restore managed line break in wrapped slot hosts - #9066
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
left a comment
There was a problem hiding this comment.
I think the right solution here is to have the default ElementDOMSlot implementation slot-aware
## Description Move empty managed-line-break normalization from the reconciler into ElementDOMSlot. The slot now suppresses an empty line break only when its own element contains a named-slot container, and it rechecks that state when slots are added or removed. Closes meta#9063 ## Test plan ### Before node node_modules/vitest/vitest.mjs --project unit --no-watch packages/lexical/src/__tests__/unit/LexicalSlot.test.ts packages/lexical/src/__tests__/unit/LexicalDOMSlot.test.tsx packages/lexical/src/__tests__/unit/LexicalReconciler.test.ts Test Files 3 passed (3) Tests 172 passed (172) ### After node node_modules/vitest/vitest.mjs --project unit --no-watch packages/lexical/src Test Files 56 passed (56) Tests 1268 passed (1268) VITEST_BROWSER=chromium,firefox,webkit node node_modules/vitest/vitest.mjs --project browser --no-watch packages/lexical/src/__tests__/browser Test Files 30 passed (30) Tests 263 passed | 4 skipped (267) TypeScript, ESLint, Prettier, git diff --check, and the pre-commit hook also pass.
|
Thanks, that direction makes sense. I moved the named-slot handling into I also added coverage for removing and adding a slot so the cached state cannot become stale. The full core unit suite passed with 1,268 tests. The browser suite passed with 263 tests across Chromium, Firefox, and WebKit, with 4 existing skips. TypeScript, ESLint, Prettier, |
## Description Named-slot containers form a contiguous prefix of an ElementDOMSlot's managed range. Check only the first node in that range when deciding whether an empty managed line break is needed. This avoids scanning every child and does not count slot containers outside an `after` boundary. Closes meta#9063 ## Test plan ### Before ```text FAIL ElementDOMSlot class > setManagedLineBreak ignores slot containers before the managed range AssertionError: expected null not to be null ``` ### After ```text Test Files 56 passed (56) Tests 1269 passed (1269) Test Files 51 passed (51) Tests 365 passed | 4 skipped (369) ``` The browser suite ran in Chromium, Firefox, and WebKit. TypeScript, ESLint, Prettier, and `git diff --check` also passed.
Description
An element with named slots can redirect its linked-list children to a separate DOM element through
getDOMSlot().withElement(...). When that child area becomes empty, it still needs a managed line break even though the host has content in a named slot.ElementDOMSlotnow owns this decision. Named-slot containers form a contiguous prefix of its managed range, so it only checks the first node after theafterboundary, or the element's first child when there is no boundary. A wrapped child area therefore receives the line break, while the default slot keeps the existing slots-only behavior. The reconciler delegates the decision on each relevant render, so adding or removing a slot updates the managed line break without leaving stale cached state.Closes #9063
Test plan
Before
The wrapped-host regression fails because the redirected content element has no managed line break. The boundary regression also fails because a slot container before the managed range incorrectly suppresses the line break.
After
The wrapped content element receives the managed line break. Removing the named slot from a childless default host restores its line break, and adding the slot again removes it. Slot containers before an
afterboundary do not affect the managed range.git diff --check, and the pre-commit hook passed.