-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bug: new paragraph can be inserted inside inline node #8083
Description
Lexical version: v0.39.0
Steps To Reproduce
- Copy the title from a google search result and pasting it into the editor.
- Press Enter at the end of the line
Screen.Recording.2026-01-17.at.23.58.57.mov
Link to code example:
The current behavior
New paragraph inserted inside LinkNode
root
└ (47) paragraph
└ (48) link "https://lexical.dev/"
├ (49) heading
| └ (50) text "Lexical"
> ├ (52) paragraph
The expected behavior
New paragraph inserted outside LinkNode
root
├ (47) paragraph
| └ (48) link "https://lexical.dev/"
| ├ (49) heading
| | └ (50) text "Lexical"
> └ (52) paragraph
Impact of fix
I discovered this corner case while reading the bug description in this PR. In cases where a link or any other inline node contains a block element, all new nodes created by pressing Enter will be placed inside that inline element.
This may be normal behavior in the case of a header split or other elements, but the insertion of a new paragraph should be outside the inline element and the parent block
Ideally, I can imagine that normalizing the tree when inserting new nodes could be done in such a way that each inline ElementNode containing block elements is copied for each block and wraps the highest inline ElementNode or TextNode. But maybe it is only necessary to correct the case with the insertion of a new paragraph