ISSUE DESCRIPTION Bug: List: delete the leading ListItemNode will also delete the…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
Assistant
There's
$createTestDecoratorNodein test utils. Let's check it and how it's used with deleteCharacter tests.Assistant
Let's write a temp test to reproduce the scenario using deleteCharacter with a block decorator followed by a ListNode.
Assistant
Vitest binary exists. Let's try running directly with node_modules/.bin/vitest with a longer timeout, in background perhaps.
Assistant
Good, environment works. The issue was my
require('lexical')call inside update. Let's fix the test to import $getSelection properly.Assistant
Now let's remove the debug logging and implement the actual fix.
Assistant
Good, restored cleanly (no console.log lines found). Now let's implement the fix.
Assistant
Now let's re-run the reproduction test.
Assistant
Let's restructure to return directly within the branch itself, removing the unreachable post-loop check.
Assistant
Now let me rewrite lines 1800-1894 cleanly with correct logic and bracket balance.
Assistant
Now let's check the rest of the loop closing and confirm brace balance is fine.
Assistant
There's a duplicate
if (state.type === 'merge-block') {line. Let me remove the duplicate.Assistant
Good, structure looks clean now. Let's verify TypeScript compiles and re-run the repro test.
Assistant
TypeScript compiles cleanly. Now let's run the existing test suites likely affected: LexicalSelection tests, LexicalHeadingNode tests, lexical-list tests.
Assistant
All pass. Now let's run broader test suites to be safe (rich-text, table since decorator merge affects tables too).
Assistant
Flat behavior preserved. Now let's clean up temp test files.
Assistant
Only the intended file is modified. Let's view the final diff.
Assistant
Clean, minimal diff. Let's run the full unit test suite once more to be certain everything passes after cleanup.
Assistant
All 157 test files (2962 tests) pass. Let's also verify no leftover backup/temp files remain.
Assistant
Clean. Now let's go through the checklist.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.