Skip to content

Bug: Weird list item state causes infinite loop on insertParagraph #7036

@amanharwara

Description

@amanharwara

Lexical version: 0.18.0 and above

Steps To Reproduce

  1. Create any list with an initial non-empty list item
  2. Press Enter and then Tab to create a nested list item, add text to it
  3. Press Enter again and in the empty nested list item, toggle off the current list (i.e. set block type to paragraph)
  4. Start typing, which will cause the text to be inserted in the last non-nested list item next to the nested list
  5. Press Enter again (basically trigger selection.insertParagraph() from that text node)

Link to code example: https://playground.lexical.dev

The current behavior

Pressing Enter in that text node causes an infinite loop.

lexical-list-item-issue.mp4

On Firefox the page freezes indefinitely. On Chrome, it throws this error after a while of freezing:

image

The expected behavior

It should correctly split the item (or create a new item if pressed Enter at the end)

Impact of fix

This makes it effectively impossible to add something new to the document if the list item is at the end of the document. Even if it is not at the end of the document, this makes the document uneditable until you refresh the page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions