Skip to content

Bug: Block cursor error on ElementNode with getDOMSlot #8561

@levensta

Description

@levensta

Lexical version: 0.44

Steps To Reproduce

  1. Implement a node that will implement the getDOMSlot() method
  2. Add this node to the editor so that the selection is set to offset 0 on this element. This can be achieved, for example, by calling the replace() method
  3. Add a new element to the child element of this node without changing the selection

Link to code example: https://codesandbox.io/p/sandbox/update-cursor-block-dcx7mp

The current behavior

An error occurs in the updateDOMBlockCursorElement function and the inserted node is not displayed until the selection changes

_block.cursor.error.mov

It is important to note that the error does not occur if selection is set to null or is on a different element

_block.cursor.happy.path.mov

The expected behavior

Nodes implementing the getDOMSlot method are correctly processed in updateDOMBlockCursorElement

Impact of fix

In addition to fixing the bug, it would be nice to have public documentation on the block cursor, as there is currently no mention of it other than the changelog

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions