Skip to content

Bug: EquationNode click yields no selection, and empty-input Backspace leaves the node behind #8533

@mayrang

Description

@mayrang

Lexical version: 0.44

Steps To Reproduce

(A) Selection on click

  1. In the playground, insert an Equation (block mode) so the editor contains only the equation as the sole root child (delete the surrounding paragraphs if needed).
  2. Click the rendered KaTeX once.
  3. Inspect $getSelection() (TreeView panel shows selection: null).

(B) Empty-input Backspace doesn't remove the equation

  1. Insert any Equation. Double-click it to open the inline LaTeX editor.
  2. Select all and delete the LaTeX so the input value is empty.
  3. Press Backspace once more.
  4. The host EquationNode is still in the document with an empty equation.

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

2026-05-21.11.59.51.mov

The current behavior

  • (A) A single click on the rendered equation does not turn into a NodeSelection. Downstream commands (Backspace, copy, arrow navigation) have no selection to act on. With no surrounding paragraph, the user is stuck — there's no caret to type into and no selection to drive a delete.
  • (B) When the LaTeX input is already empty, an extra Backspace is a no-op (browser default for an empty input). The host EquationNode persists in the editor with an empty equation, and the user has no obvious way out.

Same EquationNode behavior for inline equations as well (clicking the inline equation does not create a NodeSelection).

The expected behavior

  • (A) Clicking the rendered equation should set a NodeSelection on the EquationNode — same pattern as ImageNode / PollNode etc. The visible selection outline (.editor-equation.focused) should render. Downstream commands (Backspace to delete, copy, Enter to insert a paragraph after) should then work normally.
  • (B) Pressing Backspace inside an already-empty LaTeX input should remove the host EquationNode and place the caret at the end of the previous sibling — or, if the equation has no previous sibling, replace it with an empty paragraph so the editor stays usable.

Impact of fix

  • A block equation that ends up as the sole root child (e.g. via paste, conversion, or undoing surrounding content) leaves the editor unusable: no caret, no selection, no way to delete. Reload is the only escape.
  • Inconsistent UX vs other DecoratorNodes (Image, Poll) that do create a NodeSelection on click.
  • The empty-input Backspace dead end traps users in a state they didn't intend to reach.

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