Skip to content

[lexical] Bug Fix: Preserve first block after backward range deletion - #9236

Merged
etrepum merged 2 commits into
meta:mainfrom
Abdul-Azhar-Jamesh:main
Sep 25, 2026
Merged

etrepum merged 2 commits into
meta:mainfrom
Abdul-Azhar-Jamesh:main

Conversation

@Abdul-Azhar-Jamesh

@Abdul-Azhar-Jamesh Abdul-Azhar-Jamesh commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

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 in RangeSelection.deleteCharacter().

This PR removes that post-delete $collapseAtStart() call while preserving
$ensureRootHasParagraph(). This keeps the now-empty first block in the
document 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

@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 Sep 25, 2026
@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
lexical Ready Ready Preview Sep 25, 2026 3:50pm UTC
lexical-playground Ready Ready Preview Sep 25, 2026 3:50pm UTC

Request Review

@etrepum

etrepum commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

@Abdul-Azhar-Jamesh Abdul-Azhar-Jamesh changed the title Fix: [lexical] Backspace over all the text of the first block also removes the block #9233 [lexical] Bug Fix: Preserve first block after backward range deletion Sep 25, 2026
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Sep 25, 2026
@Abdul-Azhar-Jamesh

Copy link
Copy Markdown
Contributor Author

@etrepum sorry about that fixed it now

@etrepum
etrepum added this pull request to the merge queue Sep 25, 2026
Merged via the queue into meta:main with commit b0f5225 Sep 25, 2026
46 checks passed
@etrepum etrepum mentioned this pull request Sep 28, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 899ac1ee Deployed Sep 25, 2026 by vercel[bot]
Preview – lexical-playground — 899ac1ee Deployed Sep 25, 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. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: [lexical] Backspace over all the text of the first block also removes the block

2 participants