Skip to content

[lexical][lexical-table] Bug Fix: forward delete removes an empty block before a table - #8946

Closed
LeSingh1 wants to merge 1 commit into
facebook:mainfrom
LeSingh1:fix-8075-forward-delete-empty-block-before-shadow-root
Closed

[lexical][lexical-table] Bug Fix: forward delete removes an empty block before a table#8946
LeSingh1 wants to merge 1 commit into
facebook:mainfrom
LeSingh1:fix-8075-forward-delete-empty-block-before-shadow-root

Conversation

@LeSingh1

@LeSingh1 LeSingh1 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Repro from the issue: first line empty, table second, caret on the empty line, press fn+Delete. Nothing happens.

RangeSelection.forwardDeletion bails out of forward delete whenever the block after the anchor is a shadow root, so a table is never merged into the preceding block. That made deleteCharacter return before it reached its own caret walk, which already knows how to remove an empty block next to a shadow root — the branch backwards delete uses.

An empty block has nothing that could be merged into it, so deleteCharacter now falls through to that walk when the anchor block is empty and the shadow root is its sibling. The empty block is removed, the table stays put and the caret lands in its first cell, matching what backwards delete already does.

Deleting forwards from a block that still has content, and from an empty block at the end of a shadow root (the last block of a table cell), both still bail out and are covered by tests.

Tests: 3 in LexicalSelection.test.ts, 3 in LexicalTableSelection.test.tsx. packages/lexical 1250 pass, packages/lexical-table 156 pass.

Fixes #8075

…ck before a table

Forward delete (fn+Delete) on an empty paragraph that sits directly before a
table did nothing. RangeSelection.forwardDeletion bails out whenever the block
after the anchor is a shadow root, so that a table is never merged into the
preceding block, and deleteCharacter returned before reaching the caret walk
that already knows how to remove an empty block next to a shadow root.

An empty block has nothing that could be merged into it, so deleteCharacter now
falls through to the caret walk in that case, which removes the empty block and
leaves the shadow root alone - the same result backwards delete already
produces. The relaxation only applies when the shadow root is a sibling of the
empty block, so forward delete from an empty block at the end of a shadow root
(the last block of a table cell) still bails out and does not pull the next
cell in.
@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:18am
lexical-playground Ready Ready Preview Aug 7, 2026 9:18am

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 Aug 7, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Aug 7, 2026
@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
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.

Bug: Delete key does not delete empty line before a table

2 participants