Skip to content

[lexical] Bug Fix: delete the adjacent ElementNode from a block cursor - #8945

Closed
LeSingh1 wants to merge 1 commit into
meta:mainfrom
LeSingh1:fix/8939-block-cursor-delete-element
Closed

LeSingh1 wants to merge 1 commit into
meta:mainfrom
LeSingh1:fix/8939-block-cursor-delete-element

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

A block cursor is rendered whenever the selection is an element point next to a node that $needsBlockCursorBeside — a block DecoratorNode, or a non-inline shadow root such as a table or a slot-bearing card. There is no text position at that spot, so Backspace/Delete can only mean "remove that node".

deleteCharacter only did that for a decorator. For an ElementNode the caret walk descends into it as a ChildCaret and hits the "don't merge with a shadow root block" guard, which returns without deleting anything unless the anchor is an empty block — so a block cursor between two cards did nothing at all, in either direction.

This removes the adjacent node when the collapsed anchor is an element point beside a block-cursor ElementNode. Decorators keep going through the existing branch, which also honours isIsolated().

Tests cover both directions against a decorator and a shadow root side by side (the decorator cases pin the behaviour that already worked), backspace after the last shadow root, and the two boundaries: an empty block next to a shadow root still removes the block, and a plain paragraph still merges.

Fixes #8939

A block cursor is rendered whenever the selection is an element point next
to a node that $needsBlockCursorBeside — a block DecoratorNode, or a
non-inline shadow root such as a table or a slot-bearing card. There is no
text position at that spot, so Backspace/Delete can only mean "remove that
node".

deleteCharacter only did that for a decorator. For an ElementNode the caret
walk descended into it as a ChildCaret and hit the "don't merge with a
shadow root block" guard, which returns without deleting anything unless
the anchor is an empty block — so a block cursor between two cards did
nothing at all.

Remove the adjacent node when the collapsed anchor is an element point
beside a block-cursor ElementNode. Decorators keep going through the
existing branch, which also honours isIsolated().

Fixes meta#8939
@vercel

vercel Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Aug 7, 2026 9:09am
lexical-playground Ready Ready Preview Aug 7, 2026 9:09am

Request Review

@LeSingh1

Copy link
Copy Markdown
Contributor Author

Consolidated into #9058 with the other PRs that share this defect, per @etrepum's note on #9027 and @mayrang's on #9035. Same fix and same tests, one review.

@LeSingh1 LeSingh1 closed this Aug 10, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 5a51f7ac Deployed Aug 7, 2026 by vercel[bot]
Preview – lexical-playground — 5a51f7ac Deployed Aug 7, 2026 by vercel[bot]
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: The block cursor between ElementNodes does not delete the node

1 participant