Bug: Editor becomes uneditable when a block DecoratorNode is the only root child
Lexical version: 0.44.0 (latest main, commit e65fcd7c8)
Steps To Reproduce
- Open https://playground.lexical.dev/
- Insert a block DecoratorBlockNode (e.g. YouTube via the slash menu, URL like
https://www.youtube.com/watch?v=dQw4w9WgXcQ) - Remove the paragraph above the decorator (Backspace at the paragraph start) so the block decorator becomes the only root child
- Click the decorator so it is focused as a NodeSelection (a focus ring appears)
- Press Enter
Link to code example: https://playground.lexical.dev/
The current behavior
Nothing happens. The KEY_ENTER_COMMAND handler registered by registerRichText bails out at the $isRangeSelection(selection) guard — for a NodeSelection it just returns false. There is no paragraph to type into, and the keyboard has no way out of the NodeSelection state.
https://github.com/user-attachments/assets/d697fc05-3cdb-4c3d-899d-b00f26cbaa56
The expected behavior
A new empty paragraph should be inserted after the decorator and the caret should land in it, so the user can keep typing — matching the common pattern in other editors where pressing Enter on a selected block creates a new line below it.
Impact of fix
Whenever a user removes the surrounding paragraphs of a block decorator (image, YouTube, etc.), the editor becomes uneditable from the keyboard. The fix is small (a NodeSelection branch in the rich-text Enter handler) and unblocks an otherwise common state.