facebook / facebook/lexical

Bug: Selection cursor grabs empty adjacent parent nodes

Open
#5,124 4 comments 0 reactions 0 assignees View on GitHub
core
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 14h
Merged PRs (30d)
57

Description

When using `Shift+Up` or selecting with the mouse drag, the selection cursor tends to grab adjacent parent nodes (and none of their content). The end result of this is that any cut/copy/paste actions insert an empty parent node.

Example using paragraphs with `Shift+Up`, although the same applies to using the mouse:
https://github.com/facebook/lexical/assets/21961100/b2b1b30d-680e-4a10-b9df-e93aa1421248

Lexical version: v0.12.2

## Steps To Reproduce

1. Type a word
2. Hit enter
3. Type another word
4. Use `Shift+Up` to select the whole second paragraph
5. Copy+paste

You will see an empty paragraph node inserted. This is because the selection contains the first `ParagraphNode` but none of the child nodes within it.

## The current behavior
Extra empty nodes are being inserted.

## The expected behavior
Only nodes containing content should be inserted.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.