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 backspace/removal path, add a focused regression test around a preceding decorator block, then run the narrow unit suite and relevant checks.
- Assistant
rgisn’t installed in this checkout, so I’m using targetedfind/grepsearches instead. I’m narrowing this to the list command handlers and existing list deletion tests. - Assistant
The failure is in the generic backward-delete path: it encounters the preceding block decorator before giving
ListItemNode.collapseAtStart()a chance to turn the leading list item into a paragraph. I’m adding the regression at that boundary so it verifies both preservation of the decorator and removal of list formatting. - Assistant
The regression now passes: backspace converts the list item to a paragraph and leaves the decorator intact. I’m checking adjacent-decorator deletion coverage next, because this code also governs ordinary paragraphs and isolated decorators and those behaviors must remain unchanged.
- Assistant
Core selection tests, the full list-item test file, formatting, and targeted lint all pass. I’m doing the TypeScript check and one final diff/status review now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.