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

    Now let's write a reproduce script using jest test format, run via existing test runner but as a scratch test file outside repo test dirs (won't be added to repo), then delete after.

  3. Claude Assistant

    Uses vitest. Let's create a temp test file and run vitest for it.

  4. Claude Assistant

    Restored. Let's use the edit tool instead for precise insertion.

  5. Claude Assistant

    Let's use the replace command to insert debug logging safely (no shell interpolation issues).

  6. Claude Assistant

    Now also log the "anchor.origin" info before the loop, and run the test.

  7. Claude Assistant

    Now let's view the exact current section to craft a precise replace.

  8. Claude Assistant

    Now let's test with our repro test.

  9. Claude Assistant

    Right, my SEARCH block itself ended with } else if ( which duplicated with what follows, causing stray marker text. Let me fix line 1878 directly with edit.

  10. Claude Assistant

    Now remove the duplicate stray line 1878.

  11. Claude Assistant

    Now let's verify the whole block compiles fine and run repro test.

  12. Claude Assistant

    Good, this looks correct now. Let's run the repro test.

  13. Claude Assistant

    Legacy behavior preserved for a plain paragraph directly adjacent to a decorator (decorator removed as before). Now let's run the full existing test suites to check nothing else broke.

  14. Claude Assistant

    Now let's run the full lexical, lexical-list, lexical-rich-text unit test suites broadly.

  15. Claude Assistant

    All 1268 tests pass. Now let's also check lexical-table and lexical-playground e2e-related regression test files exist for decorator+table scenarios that might rely on similar code paths, plus run broader repo test suite for lexical-react and any other affected packages.

  16. Claude Assistant

    All 2962 unit tests pass across the entire monorepo. Now let's double check git diff and clean up.

  17. Claude Assistant

    Good, clean diff with only the intended change. Let's view the final diff to review it fully.

  18. Claude Assistant

    No TypeScript errors related to our change. Let's also run the eslint check on the modified file to catch lint issues.

  19. Claude Assistant

    No lint errors. Let's also double check for edge case: nested lists (indented list item as first item of nested list, previous outer sibling being a decorator won't normally happen, but let's also verify normal list-merging test (#7246 regression) still passes precisely with our change.

  20. Claude Assistant

    That matches the original #7246 regression test's expected output exactly. Let's clean up the temp test file.

  21. Claude Assistant

    Now let's also test nested list (indented) scenario to be thorough — first item of a nested (indented) list, backspace should unindent per collapseAtStart, not eat outer content.

  22. Claude Assistant

    Now let's do a final full test run to make sure everything is clean, plus check lint/typecheck once more.

  23. Claude Assistant

    All 2962 tests pass, 0 failures. Let's view the final diff once more for a clean review.

  24. Claude Assistant

    Good, .is() exists and handles null gracefully. Let's simplify the IIFE into a plain boolean expression for cleanliness.

  25. Claude Assistant

    Now let's run the tests again to confirm everything still passes after this cleanup.

  26. Claude Assistant

    All clean. Let's do the final full-suite check once more and confirm git diff.

  27. Claude Assistant

    All 2962 tests pass with a clean, minimal diff limited to packages/lexical/src/LexicalSelection.ts.

    Checklist review

    • If an error was reported in the issue description, I have successfully reproduced it. Yes. I wrote a temporary unit test (removed before submission) building a document with a block DecoratorNode followed by a ListNode containing one ListItemNode with text. Calling selection.deleteCharacter(true) at the start of the list item reproduced the exact bug: the previous DecoratorBlockNode was deleted (in one variant the entire List also vanished without conversion to a paragraph).

    • If an error was reported in the issue description, I have confirmed that my fix resolves the error. Yes. After the fix, the same repro now yields ['test_decorator', 'paragraph'] — the decorator is preserved and the list is converted into a paragraph (matching the reporter's preferred expected behavior), for both the case where the first list item has text and where it's empty.

    • I have thought about edge cases and made sure my fix handles them as well. I verified:

      • A plain paragraph directly adjacent to a decorator (no list wrapper) still deletes the decorator — legacy/existing behavior for genuinely adjacent blocks is preserved.
      • The existing regression test scenario for issue #7246 (merging a paragraph into the last item of a preceding list) still behaves identically.
      • Nested/indented lists: confirmed that a separate, pre-existing bug in ListItemNode.collapseAtStart (losing content when unindenting a nested item, unrelated to decorators) already existed before my change and is out of scope for this issue — my change does not regress any previously-passing behavior in that area (it was already broken/untested).
      • The isolated decorator branch (isIsolated()) is unaffected, and the "select decorator via NodeSelection when anchor is an empty element" branch is preserved for genuine same-level adjacency.
    • 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) across the entire monorepo: 157 test files, 2962 tests passed, 1 skipped, 0 failed. Also verified tsc --noEmit and eslint report no issues for the modified file.

    Let's clean up any leftover temp files and submit.

  28. Claude Assistant

    This is the final, clean diff. Let's submit.

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