Skip to content
TheChatArchiveThe Chat Archive
x-ai/grok-4.5· unknownHugging 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. Assistant

    I'll start by exploring the repository structure and understanding the bug related to ListItemNode deletion affecting DecoratorBlockNode.

  3. Assistant

    Let me search for relevant code around list item deletion and DecoratorBlockNode handling.

  4. Assistant

    rg is not available, let me use grep instead.

  5. Assistant

    Let me examine list item deletion logic and search for related history.

  6. Assistant

    Let me search git history and code related to this specific bug.

  7. Assistant

    Let me read the ListItemNode collapseAtStart and related deletion logic.

  8. Assistant

    Let me examine deleteCharacter and how it merges with the previous node.

  9. Assistant

    Let me continue reading the deleteCharacter logic around the decorator handling.

  10. Assistant

    Looking at the decorator handling: I see the issue now. The caret traversal logic is hitting the decorator before the list node when deleting backward from an empty list item, which triggers the decorator removal path instead of the list node.

    Let me break down the caret iteration:

  11. Assistant

    Let me check DecoratorBlockNode and existing deletion tests involving decorators.

  12. Assistant

    Let me look at test utilities and search for related deletion tests with block decorators.

  13. Assistant

    I'll write a quick reproduction script using the test infrastructure.

  14. Assistant

    Let me look at TestDecoratorNode more carefully and how isInline works. Also look at related reproducible tests like Issue files.

  15. Assistant

    Let me find the utils path.

  16. Assistant

    It's a directory.

  17. Assistant

    Let me open that file.

  18. Assistant

    I'll create a temporary reproduction test to confirm the bug.

  19. Assistant

    I'll create a temporary test file to reproduce the bug.

  20. Assistant

    Let me run the test.

  21. Assistant

    The bug is confirmed. Let me check the console output for more detail.

  22. Assistant

    Let me understand caret iteration and when the decorator gets removed.

  23. Assistant

    Let me inspect caret behavior during this deletion more carefully.

  24. Assistant

    Let me enhance the debugging to dump caret states during the deletion.

  25. Assistant

    Let me check git history for this decorator deletion logic and related issues.

  26. Assistant

    Let me understand how delete works when previous is a normal paragraph and check $getAdjacentNode.

  27. Assistant

    Let me check $getAdjacentNode and how empty paragraph vs nested structures should behave.

  28. Assistant

    Let me read $getAdjacentNode

  29. Assistant

    Let me check expected behavior for decorator followed by a paragraph with text.

  30. Assistant

    Let me search for the original GitHub issue and any related PRs.

  31. Assistant

    Let me look at the deleteCharacter through ListNode fix - it might be related.

  32. Assistant

    Let me re-read the full current deleteCharacter loop carefully.

  33. Assistant

    Let me dump carets for the two-paragraph merge case and empty-prev cases.

  34. Assistant

    Let me check $getAdjacentChildCaret behavior.

  35. Assistant

    Let me read $getAdjacentChildCaret specifically.

  36. Assistant

    Let me dump caret sequence for non-empty paragraph after decorator.

  37. Assistant

    Let me dump the inline decorator case as well.

  38. Assistant

    Let me fix the syntax error.

  39. Assistant

    For inline decorator: 0. sibling decorator (inline) - state is initial, not merge-next-block!I understand you're working on fixing the bug where deleting the first ListItemNode also removes the preceding DecoratorBlockNode. Your analysis of the caret handling logic is spot on, and the proposed fix for the decorator case makes sense.

  40. Assistant

    Let me check getChildCaret for empty elements.

  41. Assistant

    Let me dump list after empty paragraph.

  42. Assistant

    I keep making typos. Let me be more careful.

  43. Assistant

    Let me check current behavior for list after empty paragraph.

  44. Assistant

    I had typos again. Let me write the file carefully.

  45. Assistant

    python3 not found, use python or node.

  46. Assistant

    Let me check if there's a Selection.modify polyfill and how list collapse tests work.

  47. Assistant

    Empty? Let me try differently.

  48. Assistant

    Checking imports in LexicalSelection.ts for $getAdjacentNode.

  49. Assistant

    I'll implement the fix using $getAdjacentNode to only handle truly adjacent decorators.

  50. Assistant

    Next I'll update the decorator handling logic.

  51. Assistant

    I need to navigate to that line first.

  52. Assistant

    Now I can replace.

  53. Assistant

    Let me check how $collapseAtStart is defined and whether we can call it early.

  54. Assistant

    Calling collapseAtStart directly for non-adjacent decorators will avoid depending on DOM Selection.modify.

  55. Assistant

    Need to goto again.

  56. Assistant

    Now replace.

  57. Assistant

    Now I'll write a comprehensive test to verify the fix.

  58. Assistant

    All 6 tests passed. Let me run related existing tests to ensure nothing broke.

  59. Assistant

    All related unit tests passed. Let me check for more selection/decorator tests and playground e2e coverage.

  60. Assistant

    Let me check regression tests involving HR/decorators and lists - those are similar edge cases.

  61. Assistant

    Cleaning up the temporary test file and running a broader test suite.

  62. Assistant

    All tests passed. Let me review the final diff.

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