Repository navigation
[lexical][lexical-selection][lexical-list] Bug Fix: Skip named-slot values in block converters, diagnose replace() on a slot value, and delete slot-bearing decorator hosts at the selection boundary - #8905
Merged
etrepum merged 2 commits intoAug 4, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
marked this pull request as ready for review
August 2, 2026 03:57
etrepum
requested review from
acywatson,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 2, 2026 03:57
etrepum
force-pushed
the
claude/elementnode-replace-audit-ahvm8e
branch
from
August 2, 2026 04:25
1d47702 to
be0aa3c
Compare
etrepum
force-pushed
the
claude/elementnode-replace-audit-ahvm8e
branch
from
August 2, 2026 04:27
be0aa3c to
7ecc2f4
Compare
etrepum
force-pushed
the
claude/elementnode-replace-audit-ahvm8e
branch
from
August 2, 2026 04:30
7ecc2f4 to
438c50d
Compare
etrepum
force-pushed
the
claude/elementnode-replace-audit-ahvm8e
branch
from
August 2, 2026 04:33
438c50d to
da12bff
Compare
…alues in the remaining block converters and diagnose replace() on a slot value ## Description Follow-up to meta#8901 (fix for meta#8894), which made $setBlocksType skip named slot values. The same crash class exists in every other selection-driven block converter that resolves the current block and replaces it through the tree API, and a direct replace() of a slot value still fails with the unhelpful generic "Expected node %s to have a parent" invariant. This audits and fixes the rest, applying the same rule: a slot value's assignment is managed by the node or extension that owns the slot, so generic converters leave it as-is. The eligibility checks test the slot up-link ($getSlotHost) rather than parentless-ness, so a detached node is never conflated with a slot value and keeps failing loudly. - lexical: LexicalNode.replace() on a slot value now throws a slot-specific invariant before any mutation ("use $setSlot on its host to assign a replacement"), mirroring the existing $removeFromParent guard for remove() on a slotted node. - @lexical/selection: the deprecated $wrapNodes no-ops when the selection lives in a bare-block slot frame (it previously threw in the sibling walk); a shadow-root slot value still wraps its own subtree normally. - @lexical/list: $insertList skips slot values in its empty-block branch, its empty-list-item branch, and its walk-up list-type-change branch; $removeList skips a slotted top-level list (they previously threw or vacated the slot). - @lexical/markdown: audited, already safe — the element/multiline shortcut runners bail unless the block's parent is a root or shadow root, which excludes slot values. The rule is documented in the named-slots concepts page. ## Test plan ### Before $insertList, $removeList, and $wrapNodes threw "Expected node %s to have a parent" (or silently vacated a slot) when the selection was inside a bare-block named-slot value or a slotted list; replace() on a slot value threw the same generic invariant. ### After The converters leave slot values as-is and replace() on a slot value throws a diagnostic pointing at $setSlot. New unit tests in LexicalSetBlocksTypeSlots.test.ts and LexicalFormatListSlots.test.ts, plus a replace() test in LexicalSlot.test.ts.
etrepum
force-pushed
the
claude/elementnode-replace-audit-ahvm8e
branch
from
August 2, 2026 04:36
da12bff to
4ad0642
Compare
…ion boundary ## Description Backspace with the caret at the boundary after a slot-bearing DecoratorNode host (e.g. the playground PullQuote) was a silent no-op: deleteCharacter special-cased slot-bearing decorators to never be removed via backspace, leaving them undeletable from the keyboard. Remove that special case so a slot-bearing decorator behaves like any other block decorator at the boundary: backspace removes it as a whole unit (slots included), and from an adjacent empty paragraph it drops the paragraph and node-selects the host so the next backspace deletes it. The ElementNode-host merge guard is intentionally unchanged: a cross-block merge would keep the host's children while silently dropping its slots, so backspace at the start of a slot-bearing host's child still leaves the host in place. Closes meta#8904 ## Test plan ### Before With the caret at the start of the block after a slot-bearing decorator host, Backspace did nothing; the host could not be deleted from the keyboard. ### After Backspace removes the host (or node-selects it from an adjacent empty paragraph, matching normal block decorator behavior). New unit tests in LexicalSlot.test.ts cover both cases; the existing test that a slot-bearing ElementNode host is not merged away still passes.
Contributor
|
Ship-worthy. ✅ Checked out the PR, ran the tests (136/136 pass, incl. the 101-test ✅ What's right (verified)
🟡 Minor (non-blocking)
🔵 Nits (cosmetic)
🔎 Uncaught cases considered — all OK
|
potatowagon
approved these changes
Aug 3, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Aug 3, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Aug 3, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Aug 4, 2026
etrepum
pushed a commit
to etrepum/lexical
that referenced
this pull request
Aug 6, 2026
Conflicts resolved: - formatList.ts: compose upstream's named-slot guard (meta#8905) with this branch's $copySemanticNestingMark — the mark copy now happens inside the slot-host check, alongside the children move it annotates. - registerList.ts: accept upstream's removal of the decorator-adjacent backspace handler (meta#8871); the semantic parking that handler carried lives in ListItemNode.collapseAtStart, which the core deleteCharacter path invokes, and registerListBackspaceDecorator.test.ts still passes. Drop the now-unused $parkNestedListsInWrapper import here. Also align this branch's ARROW_RIGHT registration with upstream's registerCommand generics removal (meta#8877 follow-up, meta#8871 series). Verified: tsc clean; 872 list/markdown/mdast unit tests, 51 browser tests, and 4267 core/react/html/selection/rich-text tests pass. Co-Authored-By: Claude Fable 5 <[email protected]>
Merged
This was referenced Sep 9, 2026
AlessioGr
added a commit
to payloadcms/payload
that referenced
this pull request
Sep 10, 2026
Upgrades `lexical` and every installed `@lexical/*` package from `0.48.0` to `0.50.0` for Payload 4.x (`main`). Updates the dependency pins, lockfile, `lexicalTargetVersion`, and v4 migration guide. ## Breaking changes **No application changes or data migration are needed when using Payload's built-in rich text features.** If you maintain custom rich text features, check that they still compile and that custom content loads, copies, and pastes correctly. Lexical tightened some TypeScript types and changed how custom nodes are loaded and copied. Tests that inspect the editor's HTML may also need updated selectors or snapshots because Lexical adds some internal markup. **Do not install `lexical` or `@lexical/*` yourself for use with Payload.** Remove any direct dependencies you added for the editor and use Payload's re-exports from `@payloadcms/richtext-lexical/lexical` and `@payloadcms/richtext-lexical/lexical/*`. Payload supplies the matching versions; mixing versions can break the editor. This is the existing [custom feature requirement](https://payloadcms.com/docs/rich-text/custom-features). ## Breaking changes and Payload migrations Reviewed [0.49.0](https://github.com/facebook/lexical/releases/tag/v0.49.0) and [0.50.0](https://github.com/facebook/lexical/releases/tag/v0.50.0). Listed below are breaking API/type changes and behavior changes explicitly identified as breaking in the release notes. Deprecations and routine bug fixes are omitted. **Yes** means we had to change Payload code; **No** means no Payload migration was required. | Release | Breaking change | Required migration in Payload | Changes made | | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | | 0.49 | [Built-in nodes adopt `$config()`](meta/lexical#8640). Direct static `importJSON`, `importDOM`, `clone`, and `transform` implementations change; `__type` becomes readonly and automatic node construction needs zero-argument defaults. Custom static implementations remain supported. | No | - | | 0.49 | [`LexicalCommand<T>` checks its payload type more strictly](meta/lexical#8877). `LexicalCommand<unknown>` is no longer a safe catch-all. | Yes | Focus and blur commands were incorrectly registered with `MouseEvent`. Removed the explicit types so Lexical infers `FocusEvent`. | | 0.50 | [Named-slot values cannot be replaced with `LexicalNode.replace()`](meta/lexical#8938). Block converters also [skip slot values](meta/lexical#8905). | No | - | | 0.50 | [Lexical JSON clipboard copying checks `excludeFromCopy('clone')`, not `'html'`](meta/lexical#8995). | No | - | Also updated the copied table action menu for merged-cell bounds, header toggles, and merge/unmerge selection, and fixed the upload alignment test’s image selector. The nested toolbar wheel test now hovers each toolbar before scrolling; its assertions are unchanged. Both affected e2e tests pass locally in Chromium on TanStack. Formatting and diff checks pass. ## Previous Lexical upgrades - [#17554](#17554) — 0.45.0 → 0.48.0 - [#17064](#17064) — 0.41.0 → 0.45.0 - [#15760](#15760) — 0.35.0 → 0.41.0
AlessioGr
added a commit
to payloadcms/payload
that referenced
this pull request
Sep 11, 2026
Upgrades `lexical` and every installed `@lexical/*` package from `0.41.0` to `0.50.0` for Payload 3.x. Updates the dependency pins, lockfile, and `lexicalTargetVersion`. Also exposes the 15 React entry points added on main in [#17554](#17554) through `@payloadcms/richtext-lexical/lexical/react/*`, so custom features can use these APIs through Payload. ## Breaking changes **No application changes or data migration are needed when using Payload's built-in rich text features.** If you maintain custom rich text features, check that they still compile and that custom content loads, copies, and pastes correctly. Lexical removed some older APIs, tightened TypeScript types, and changed how custom nodes are loaded and copied. Tests that inspect the editor's HTML may also need updated selectors or snapshots because Lexical adds some internal markup. **Do not install `lexical` or `@lexical/*` yourself for use with Payload.** Remove any direct dependencies you added for the editor and use Payload's re-exports from `@payloadcms/richtext-lexical/lexical` and `@payloadcms/richtext-lexical/lexical/*`. Payload supplies the matching versions; mixing versions can break the editor. This is the existing [custom feature requirement](https://payloadcms.com/docs/rich-text/custom-features). The 3.x Markdown implementation and converter defaults are preserved. This does not backport the v4 Markdown API changes. ## Breaking changes and Payload migrations Reviewed [0.42.0](https://github.com/facebook/lexical/releases/tag/v0.42.0), [0.43.0](https://github.com/facebook/lexical/releases/tag/v0.43.0), [0.44.0](https://github.com/facebook/lexical/releases/tag/v0.44.0), [0.45.0](https://github.com/facebook/lexical/releases/tag/v0.45.0), [0.46.0](https://github.com/facebook/lexical/releases/tag/v0.46.0), [0.47.0](https://github.com/facebook/lexical/releases/tag/v0.47.0), [0.48.0](https://github.com/facebook/lexical/releases/tag/v0.48.0), [0.49.0](https://github.com/facebook/lexical/releases/tag/v0.49.0), [0.50.0](https://github.com/facebook/lexical/releases/tag/v0.50.0). Listed below are breaking API/type changes and behavior changes explicitly identified as breaking in the release notes. Deprecations and routine bug fixes are omitted. **Yes** means we had to change Payload code; **No** means no Payload migration was required. | Release | Breaking change | Required migration in Payload | Changes made | | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 0.42 | [Experimental `hasFitNestedTables` moves out of the table package into the playground](meta/lexical#8210). | No | - | | 0.42 | [The deprecated context-menu plugin is removed](meta/lexical#8199). | Yes | Removed the invalid `LexicalContextMenuPlugin` proxy and package export. Custom consumers must use `@payloadcms/richtext-lexical/lexical/react/LexicalNodeContextMenuPlugin` and adapt to its node-context-menu API. | | 0.43 | [Nested editors delegate asynchronously to their parent](meta/lexical#8308), restoring the behavior from before 0.42.0. | No | - | | 0.45 | [`$getReconciledDirection` now inherits direction through shadow-root nodes](meta/lexical#8479). | No | - | | 0.45 | [Backspace at the start of a non-empty block preserves the current block type and formatting](meta/lexical#8493). | No | - | | 0.45 | [Moving nodes between parents adjusts selection offsets](meta/lexical#8501). | No | - | | 0.45 | [Markdown shortcuts can trigger when IME composition commits](meta/lexical#8503). | No | - | | 0.45 | [Rich/plain text automatically removes empty inline elements](meta/lexical#8497). | No | - | | 0.45 | [Triple-click selection normalization moves from core into rich/plain text registration](meta/lexical#8520). Editors bypassing that registration must add `NormalizeTripleClickSelectionExtension`. | No | - | | 0.45 | [`DOMSlot` and the DOM rendering override APIs are generalized](meta/lexical#8519); playground `AutocompleteNode` is replaced by `VisibleLineBreakExtension`. | No | - | | 0.46 | [`static importJSON` widens its parameter to `SerializedLexicalNode & Record<string, unknown>`](#17554). Overrides using serialized interfaces can fail TypeScript checks. | No | - | | 0.46 | [Node lookups and traversal no longer infer unchecked subclass types](meta/lexical#8661). Explicit unchecked traversal generics are deprecated. | Yes | Removed the upload drawer’s assumption that a node lookup returns `UploadNode`. Added `$isUploadNode` before reading or updating upload data. | | 0.46 | [DOM lookups of the editor root return `RootNode` instead of `null`](meta/lexical#8588). Selection-capture handling is also generalized beyond decorators. | No | - | | 0.46 | [`insertNodes` preserves leading line breaks, and managed line breaks receive a DOM marker](meta/lexical#8615). | No | - | | 0.46 | [Experimental DOM-import rules register through node extensions](meta/lexical#8662); the separate per-package import extensions become deprecated aliases. | No | - | | 0.46 | [Experimental named slots change the Yjs sync signature](meta/lexical#8603): `syncLexicalUpdateToYjsV2__EXPERIMENTAL` gains a `dirtyLeaves` parameter. | No | - | | 0.46 | [Copying an element through `NodeSelection` includes its children](meta/lexical#8603), instead of copying an empty shell. | No | - | | 0.46 | [Previously deprecated exports are removed](meta/lexical#8704): `toggleLink`, `insertList`, `removeList`, and ContentEditable’s `Props` alias. Replacements are `$toggleLink`, `$insertList`, `$removeList`, and `ContentEditableProps`. | No | - | | 0.47 | [React 17 support is removed](meta/lexical#8782); React 18 or later is required. | No | - | | 0.47 | [Segmented text temporarily switches to normal mode during IME composition while keeping its DOM](meta/lexical#8784). Subclasses must tolerate that temporary mode. | No | - | | 0.49 | [Built-in nodes adopt `$config()`](meta/lexical#8640). Direct static `importJSON`, `importDOM`, `clone`, and `transform` implementations change; `__type` becomes readonly and automatic node construction needs zero-argument defaults. Custom static implementations remain supported. | No | - | | 0.49 | [`LexicalCommand<T>` checks its payload type more strictly](meta/lexical#8877). `LexicalCommand<unknown>` is no longer a safe catch-all. | Yes | Focus and blur commands were incorrectly registered with `MouseEvent`. Removed the explicit types so Lexical infers `FocusEvent`. | | 0.50 | [Named-slot values cannot be replaced with `LexicalNode.replace()`](meta/lexical#8938). Block converters also [skip slot values](meta/lexical#8905). | No | - | | 0.50 | [Lexical JSON clipboard copying checks `excludeFromCopy('clone')`, not `'html'`](meta/lexical#8995). | No | - | Also updated the copied table action menu for merged-cell bounds, header toggles, and merge/unmerge selection, and fixed the upload alignment test’s image selector. Formatting and diff checks pass for the upload selector fix. Verified all 15 new entry points through source and published export maps with runtime imports and TypeScript checks. ESLint and formatting checks pass. ## Previous Lexical upgrades - [#15760](#15760) — 0.35.0 → 0.41.0 - [#13715](#13715) — 0.34.0 → 0.35.0 - [#13622](#13622) — 0.28.0 → 0.34.0
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
Follow-up to #8901 (fix for #8894), which made
$setBlocksTypeskip named slot values. The same crash class exists in every other selection-driven block converter that resolves the current block and replaces it through the tree API, and a directreplace()of a slot value still fails with the unhelpful generic"Expected node %s to have a parent"invariant. This audits and fixes the rest, applying the same rule: a slot value's assignment is managed by the node or extension that owns the slot, so generic converters leave it as-is. The eligibility checks test the slot up-link ($getSlotHost) rather than parentless-ness, so a detached node is never conflated with a slot value and keeps failing loudly.lexical:LexicalNode.replace()on a slot value now throws a slot-specific invariant before any mutation, including the keys and types of the value and its host for debugging (replace: node %s (type %s) is slotted into host %s (type %s); … Use $setSlot on its host to assign a replacement.), mirroring the existing$removeFromParentguard forremove()on a slotted node.@lexical/selection: the deprecated$wrapNodesno-ops when the selection lives in a bare-block slot frame (it previously threw in the sibling walk); a shadow-root slot value still wraps its own subtree normally.@lexical/list:$insertListskips slot values in its empty-block branch, its empty-list-item branch, and its walk-up list-type-change branch;$removeListskips a slotted top-level list (they previously threw or vacated the slot).@lexical/markdown: audited, already safe — the element/multiline shortcut runners bail unless the block's parent is a root or shadow root, which excludes slot values.The rule is documented in the named-slots concepts page.
The audit also turned up the inverse problem: deleting a slot-bearing host from outside. Backspace with the caret at the boundary after a slot-bearing
DecoratorNodehost (e.g. the playground PullQuote) was a silent no-op —deleteCharacterspecial-cased slot-bearing decorators to never be removed via backspace, leaving them undeletable from the keyboard. That special case is removed, so a slot-bearing decorator behaves like any other block decorator at the boundary: backspace removes it as a whole unit (slots included), and from an adjacent empty paragraph it drops the paragraph and node-selects the host so the next backspace deletes it. The ElementNode-host merge guard is intentionally unchanged: a cross-block merge would keep the host's children while silently dropping its slots, so backspace at the start of a slot-bearing host's child still leaves the host in place.Closes #8904
Test plan
Before
$insertList,$removeList, and$wrapNodesthrew"Expected node %s to have a parent"(or silently vacated a slot) when the selection was inside a bare-block named-slot value or a slotted list;replace()on a slot value threw the same generic invariant. Backspace after a slot-bearing decorator host did nothing; the host could not be deleted from the keyboard.After
The converters leave slot values as-is and
replace()on a slot value throws a diagnostic pointing at$setSlot. Backspace removes a slot-bearing decorator host at the boundary (or node-selects it from an adjacent empty paragraph, matching normal block decorator behavior). New unit tests inLexicalSetBlocksTypeSlots.test.tsandLexicalFormatListSlots.test.ts, plusreplace()and boundary-deletion tests inLexicalSlot.test.ts; the existing test that a slot-bearing ElementNode host is not merged away still passes.