Skip to content

Bug: Backspace does not move the caret to the previous shadow root element #8730

Description

@levensta

Lexical version: 0.45 latest

Steps To Reproduce

  1. Insert a shadow root element, such as CollapsibleContainer in the playground
  2. Insert a paragraph of text after the shadow root element
  3. Insert your cursor in the middle of the paragraph text and press Backspace

Link to code example: https://playground.lexical.dev/#doc=H4sIAAAAAAAAE9WTT2_CMAzFv8s7Z6gdMFiOHDhP4jjtkDUGIoW4cl00hPrdp5T9K9MmbTtMnCLbes8_28oR5IOyrNQpwR4hzJrfahuiF0qw94PgwcAHoUoDJ9jUxmiwZtk5hQUMQvKUFLYw0ENNsKiduI24eguDPUnTC0sDpSddviiLU7jSQ8wSdOZrgv_A-XmbimN0dRMeI11p0EiDdt_P50ldiL3b-p1oxz4bp5yJMGhe6U6wsFgy4w2gzw16XsSuKk6ay38kP7d0IZGcTcF13rdKS5_O8dsLLJxc5AX6Xz9A7Qyia3Tl9uRhy9m8vJ3dXE_G8-nYoOFWqqy7i-6wEW6T_6hGMZpMRwW6ZxU_aJVeBAAA

The current behavior

The caret gets stuck at the beginning of a paragraph and does not move to the previous element

cursor.stucks.before.shadow.root.mov

The expected behavior

The caret moves to the nearest available text-containing node, and the text after the caret is appended to it

Impact of fix

Similar behavior works in Notion and seems entirely expected. The only caveat is what happens if the last element in the shadow root is a decorator, such as an embed video. In this case, I see several options:

  • The caret stops at the paragraph and does not move anywhere.
  • The caret always jumps over any decorators and the text appends to the nearest available node (like in Notion)

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