-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bug: Selection issue from list transform on multi-line paragraph #8046
Copy link
Copy link
Closed
Labels
listsRelates to Lexical ListsRelates to Lexical Lists
Description
Lexical version: 0.39.0
Steps To Reproduce
- In a blank editor, enter a line of text, then insert a
linebreakwithCmd + Shift - Transform the paragraph into a list (ordered or unordered)
- Previously, the selection was on the
linebreak, after transforming it into a list, the selection is on the list node itself. We also receive this console warning:IndexSizeError: Failed to execute 'setBaseAndExtent' on 'Selection': There is no child at offset 2.
Link to code example:
This can be reproduced on the Lexical playground. It doesn't make sense to create a codesandbox for this, as it needs to be reproduced step by step. Here's a screen recording of how to reproduce it.
Screen.Recording.2025-12-22.at.10.45.04.AM.mov
The current behavior
After transforming a paragraph ending in a linebreak node into a list, we get the following console warning: IndexSizeError: Failed to execute 'setBaseAndExtent' on 'Selection': There is no child at offset 2.
Additionally, our selection is set to the list node, as opposed to the linebreak node where we left our selection state before the transformation.
The expected behavior
Expected behavior is that we don't get the console warning, and our selection state is preserved, on the linebreak node.
Impact of fix
- This bug affects a few live customers of an app using Lexical.
- If focus is preserved on list transformation, this issue is more noticeable. If the editor is refocused after the transformation, the cursor jumps from the position of the
linebreaknode, up to the beginning of the list.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
listsRelates to Lexical ListsRelates to Lexical Lists