facebook / facebook/lexical

Bug: Removing an empty paragraph with a sibling does not correctly set styles on selection

Open
#6,781 1 comment 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

Lexical version: 0.19.0

## Steps To Reproduce

1. Go to the Playground
2. Add text with a color and/or format
3. Insert a new paragraph, set the color and format to something else
4. Remove the paragraph character by character until the selection moves up to the previous paragraph
5. Begin typing

https://github.com/user-attachments/assets/d2c732d8-4172-4521-934f-043088ed4915

## The current behavior
1. After typing the selection retains the style and format from the deleted paragraph

## The expected behavior
2. The inserted text should match the style and format of the selection

## Impact of fix

Bug is 100% reliably reproducible and does not align with existing text editor behaviours.

The root cause _might_ be in `Selection.removeText`. Specifically, when removing text in this scenario, `TextNode.selectEnd` is called, but it merely updates the anchor/offset. However, the style and format are not applied from the node.

Contributor guide

Open the contributing guide

Research direction

Start in the Playground and reproduce the selection-formatting steps described in the issue. Then inspect Selection.removeText and TextNode.selectEnd, which the report identifies as the likely path. Done means newly typed text matches the style and format of the selection after the empty paragraph is removed.

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
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.