facebook / facebook/lexical

Bug: Node selection inserts additional line break node

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

Description

When I make a selection of the paragraph on top of the editor, editor adds additional node.

Lexical version: 0.12.2

https://github.com/facebook/lexical/assets/51330172/efbac5aa-2efe-482c-9cd9-2182179eaf0c

## Steps To Reproduce

```ts
const paragraphNode = $createParagraphNode()
node.insertBefore(paragraphNode)
paragraphNode.select()
```

1. Insert paragraph before the first node
2. Select it with either `select`, `selectEnd` or `selectStart` as first node

Link to code example:
https://codesandbox.io/s/happy-glade-sry4z5?file=/src/plugins/imageBlock/plugins/ImageBlockPlugin/ImageBlockPlugin.tsx

## The current behavior
Inserts node if I add `node.select()` or `node.selectStart()` or `node.selectEnd()` when I select paragraph on top of the editor

## The expected behavior
It does not insert additional node with line break

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.