Skip to content

Bug: Empty inline ElementNode is not deleted inside an other ElementNode #8205

@levensta

Description

@levensta

ℹ️ From a discord discussion https://discord.com/channels/953974421008293909/1480597126932201542

Lexical version: 0.41.0

Steps To Reproduce

  1. Create custom node that canBeEmpty and isInline methods returns true
  2. Move emptyable custom node inside ListItemNode
  3. Delete the text from the сustom node by pressing Backspace
  4. Delete ListItemNode by pressing Backspace

Link to code example: https://codesandbox.io/p/sandbox/lexical-link-inside-listitem-flp5vk

The current behavior

ListItemNode is removed, but custom InlineElement remains in state

The expected behavior

An empty inline element is also removed if its parent element is removed

Impact of fix

lexical-playground doesn't have an example of a node that can be both empty and inline, so it's unclear how common it is among Lexical users. A fix for the case without affecting the core logic would be nice anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreReconciler, DOM, Selection, Node, Events, Composition

    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