Repository navigation
[lexical] Bug Fix: Preserve first block after backward range deletion - #9236
Merged
Merged
Conversation
Abdul-Azhar-Jamesh
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
September 25, 2026 15:48
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
|
The PR title and description does not follow the repository template https://raw.githubusercontent.com/facebook/lexical/refs/heads/main/.github/pull_request_template.md |
Contributor
Author
|
@etrepum sorry about that fixed it now |
etrepum
approved these changes
Sep 25, 2026
Merged
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
Previously, pressing Backspace after selecting all text in the first block
could remove that block entirely. This was caused by the post-delete
$collapseAtStart()cleanup inRangeSelection.deleteCharacter().This PR removes that post-delete
$collapseAtStart()call while preserving$ensureRootHasParagraph(). This keeps the now-empty first block in thedocument and preserves its original block type.
Regression coverage was added for both backward deletion (Backspace) and
forward deletion (Delete).
Closes #9233
Test plan
Before
Selecting all text in the first block and pressing Backspace removed the
first block:
first
second
→ Backspace after selecting "first"
second
After
The first block remains empty and keeps its block type:
[empty first block]
second