Skip to content

Bug: SKIP_DOM_SELECTION_TAG doesn't work during state initialization #8610

@levensta

Description

@levensta

Lexical version: 0.44

Steps To Reproduce

  1. Add init state to $initialEditorState property of root extension or editorState property of InitialConfig
  2. Add $addUpdateTag(SKIP_DOM_SELECTION_TAG)
  3. Open the editor app

Link to code example: https://codesandbox.io/p/sandbox/nodestate-in-export-html-forked-tlqrkq
⚠️ Be sure to open the iframe with the application in a separate tab

The current behavior

The application initializes and scrolls to the end of the content

The expected behavior

Scrolling does not occur if the SKIP_DOM_SELECTION_TAG tag is added during the first update, i.e. initialization

Impact of fix

It's already known that $insertNodes is the recommended method for inserting generated nodes into content, as it normalizes inline elements by wrapping them in paragraphs. This function inserts nodes by changing the selection, but adding SKIP_DOM_SELECTION_TAG doesn't change anything. If this is expected behavior and initialization isn't just a first update, it would be helpful to include in the documentation the caveat that tags don't affect behavior within initialization. It would also be helpful to include an example where content is initialized using $insertNodes and scrolling is avoided

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