facebook / facebook/lexical

Bug: Unexpected behaviour when pressing backspace in empty first node

Open
#6,570 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 16h
Merged PRs (30d)
61

Description

If the selection is in an empty paragraph at the top of a lexical editor AND there are non-empty nodes below, hitting backspace removes the empty node. Text editors usually do nothing instead of deleting the empty paragraph.

Lexical version: 0.17.1

## Steps To Reproduce

1. Nav to the playground https://playground.lexical.dev
2. Place the caret at offset 0
3. Type return
4. Place the caret at offset 0 again, in the empty paragraph
5. Hit backspace

## The current behavior
Backspace in empty paragraph at head of editor deletes the paragraph.

## The expected behavior
Backspace in empty paragraph at head of editor should do nothing.

## Impact of fix
More standard behaviour, aligned with other text editors.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in the Lexical playground at https://playground.lexical.dev using the listed steps, then trace the editor's backspace handling for an empty paragraph at the top. Done means backspace leaves that empty paragraph unchanged when non-empty nodes follow it, while preserving normal backspace behavior elsewhere.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.