Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Bug: List: delete the leading ListItemNode will also delete the…

  1. User

    ISSUE DESCRIPTION

    Bug: List: delete the leading ListItemNode will also delete the previous DecoratorBlockNode Lexical version: 0.12.2

    Steps To Reproduce

    1. Open the playground at https://playground.lexical.dev/
    2. Append a DecoratorBlockNode to the document, for example, a TweetNode
    3. Insert a list after the DecoratorBlockNode
    4. Delete the first list item, and the previous DecoratorBlockNode will also be removed

    https://github.com/facebook/lexical/assets/6022672/2ccbc2a0-af27-4d3f-a244-804f43249fec

    The current behavior

    Both the ListNode and the previous DecoratorBlockNode are deleted.

    The expected behavior

    Only ListNode would be deleted. (I will be more than happy to see the ListNode be replaced by a ParagraphNode if 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /lexical, current file: none) bash-$

  2. Claude Assistant

    Let's write a quick reproduction script using the jest test environment for lexical core, simulating the caret traversal logic directly through the editor.

  3. Claude Assistant

    Uses vitest. Let's create a temp test file for reproduction.

  4. Claude Assistant

    Good, TestDecoratorNode already included, and ListNode/ListItemNode already default too. Let's write the temp test file properly using this pattern.

  5. Claude Assistant

    Now let's view exact current lines to make a precise edit.

  6. Claude Assistant

    No python3 available. Let me rewrite as node script instead.

  7. Claude Assistant

    Now let's remove the debug console.log I added earlier for testing (already restored from backup so it's clean). Let's verify no leftover console.log lines.

  8. Claude Assistant

    Good, clean. Now let's run our repro tests.

  9. Claude Assistant

    Also add a log after the loop and around modify/collapseAtStart section.

  10. Claude Assistant

    Now let's run the broader test suites: lexical-list, lexical core selection tests, lexical-rich-text (heading), and playground unit tests.

  11. Claude Assistant

    All pass. Now let's run the full lexical package unit test suite plus caret tests to be thorough.

  12. Claude Assistant

    All 986 tests pass (the DOMException stderr is pre-existing noise, unrelated). Let's also run lexical-table, lexical-code, and other packages that might use decorators/collapseAtStart to be safe.

  13. Claude Assistant

    All pass. Let's also run the entire unit test suite across the whole repo to be safe (not just selected packages).

  14. Claude Assistant

    All 157 test files / 2962 tests pass (1 skipped, pre-existing). Now let's double-check the final diff and clean up any temp files.

  15. Claude Assistant

    Clean diff, no leftover debug code or temp test files. Let's do a final sanity check by writing a temporary reproduction test once more (matching the exact issue scenario with a forward-delete direction too, and nested list edge cases), then remove it.

  16. Claude Assistant

    Good, debug logging removed. Let's confirm this content-loss behavior is pre-existing in ListItemNode.collapseAtStart itself, independent of our change, by directly invoking it.

  17. Claude Assistant

    Now let's run the full unit test suite one more time as a final sanity check before submission.

  18. Claude Assistant

    All 157 test files pass (2962 tests, 1 pre-existing skip). Let's view the final diff once more for the record.

  19. Claude Assistant

    This is the complete and final fix. Let's go through the checklist.

  20. Claude Assistant

    Checklist review

    • [x] If an error was reported in the issue description, I have successfully reproduced it. I wrote a temporary vitest reproduction (using the existing TestDecoratorNode test fixture as a stand-in for TweetNode/DecoratorBlockNode) that built Decorator + List[li1("one"), li2("two")], placed the cursor at the very start of li1's text, and called selection.deleteCharacter(true) (the same code path Backspace triggers). Before the fix, this deleted the DecoratorNode entirely, leaving only the ListNode — exactly matching the reported bug.

    • [x] If an error was reported in the issue description, I have confirmed that my fix resolves the error. After the fix, the same repro produces [decorator, list["two"]] (the decorator survives, only the first list item is consumed/merged forward as expected), and a single-item-list variant produces [decorator, paragraph] — matching the issue author's stated preference ("I will be more than happy to see the ListNode be replaced by a ParagraphNode").

    • [x] I have thought about edge cases and made sure my fix handles them as well. I checked: (1) plain non-empty paragraph directly after a decorator (existing "adjacent decorator is removed" behavior preserved), (2) plain empty paragraph directly after a decorator (existing "select decorator via NodeSelection" behavior preserved), (3) list directly after a plain paragraph, no decorator (existing cross-block text merge behavior preserved), (4) single-item list after a decorator (converts to paragraph, decorator preserved), (5) nested/indented list's first item preceded (at the outer level) by a decorator (decorator preserved; the nested-list-content-loss behavior I found there is a pre-existing, independent bug in ListItemNode.collapseAtStart's indent branch, reproducible even without any decorator or my change involved, so it's out of scope for this issue and was left untouched). The fix only changes behavior when the backward/forward deletion traversal has to ascend through more than one structural block wrapper (e.g. ListItemNode inside ListNode) before reaching a DecoratorNode — in that case it now defers to the node-specific collapseAtStart handling instead of blindly merging with/deleting the decorator.

    • [x] I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. Ran the full unit test suite (vitest --project unit run): 157 test files / 2962 tests passed (1 pre-existing skip), including all lexical-list, lexical core (LexicalSelection, LexicalCaret), lexical-rich-text, lexical-table, and other package suites. All temporary reproduction test files were removed before submission, and no test files were modified.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.