Skip to content

Bug: $getRoot().getTextContent() new line inconsistencies #8096

@bmakan

Description

@bmakan

Lexical version: 0.38.2

Steps To Reproduce

  1. Load previously stored serialized state with multiple paragraphs.
  2. Notice (console) how there are 4x \n between paragraphs.
  3. Now add a space at the end.
  4. Notice how there are now 2x \n between paragraphs.
  5. Select end and press Enter 2x and type anything.
  6. Notice there are 4x \n.

Link to code example: https://codesandbox.io/p/devbox/priceless-meadow-kmlmj2

The current behavior

Inconsistent number of new lines in between paragraphs in $getRoot().getTextContent() output.

The expected behavior

Consistent number of new lines in between paragraphs in $getRoot().getTextContent() output.

Impact of fix

I am using $getRoot().getTextContent() to get text diff between initial and final state. The inconsistencies report fake addition/removals of new lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreReconciler, DOM, Selection, Node, Events, Composition

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions