[lexical][lexical-table] Bug Fix: forward delete removes an empty block before a table - #8946
Closed
LeSingh1 wants to merge 1 commit into
Closed
Conversation
…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.
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 7, 2026 09:16
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Repro from the issue: first line empty, table second, caret on the empty line, press fn+Delete. Nothing happens.
RangeSelection.forwardDeletionbails 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 madedeleteCharacterreturn 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
deleteCharacternow 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 inLexicalTableSelection.test.tsx.packages/lexical1250 pass,packages/lexical-table156 pass.Fixes #8075