Bug: List: delete the leading ListItemNode will also delete the previous…
- User
Bug: List: delete the leading ListItemNode will also delete the previous DecoratorBlockNode Lexical version: 0.12.2
Steps To Reproduce
- Open the playground at https://playground.lexical.dev/
- Append a
DecoratorBlockNodeto the document, for example, aTweetNode - Insert a list after the
DecoratorBlockNode - Delete the first list item, and the previous
DecoratorBlockNodewill also be removed
https://github.com/facebook/lexical/assets/6022672/2ccbc2a0-af27-4d3f-a244-804f43249fec
The current behavior
Both the
ListNodeand the previousDecoratorBlockNodeare deleted.The expected behavior
Only
ListNodewould be deleted. (I will be more than happy to see theListNodebe replaced by aParagraphNodeif possible! That's the default behavior in other editors.)Interface
No new interfaces are introduced.
- Assistant
I’ll trace the list-item backspace/removal path around decorator blocks, add a focused regression test, then run the narrow list test suite and relevant type/lint checks.
- Assistant
rgisn’t installed in this checkout, so I’m switching to targetedfind/grepsearches. The repository status is clean so far. - Assistant
The failure sits at the boundary between core deletion and
ListItemNode.collapseAtStart(): deletion can encounter the preceding block decorator before the list has a chance to convert its leading item into a paragraph. I’m building the regression at that boundary so it covers the actual key behavior, not just direct node removal. - Assistant
The regression is now reproduced: with a non-empty first list item, Backspace at its start removes the decorator and leaves the list untouched. The core deletion walker reaches the decorator before invoking the list item’s collapse behavior. I’m changing that ordering only when a decorator is encountered, allowing structural nodes such as list items to handle Backspace first.
- Assistant
The focused regression and the core selection suite now pass (93 tests). The resulting document is exactly
block decorator + paragraph("item"): the decorator survives, the list wrapper is removed, and the item content/selection behavior is retained. I’m doing the final formatting and static checks now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.