Skip to content

Bug: When AutoFocusPlugin is Combined with CodeHighlightPlugin and LexicalOnChangePlugin - an OnChange Event is raised on document load. #4493

Open
@58bits

Description

@58bits

When the React AutoFocusPlugin, (@lexical/react/LexicalAutoFocusPlugin) React OnChangePlugin (@lexical/react/LexicalOnChangePlugin) and the CodeHighlightPlugin (calling {registerCodeHighlighting} from '@lexical/code') are all enabled in the editor - then when the application first loads the document / editor and is 'AutoFocused' - an OnChange event is raised.

Pretty sure it's being caused by the code highlighter registration - but it only happens when the AutoFocus (or the call to editor.focus()) occurs (i.e. it doesn't happen when the editor is manually focused by clicking inside the editor window).

Lexical version: 0.10.0

Steps To Reproduce

  1. Enable all three plugins - AutoFocusPlugin, OnChangePlugin, and CodeHighlightPlugin
  2. Close the document / editor application and then re-open and existing document / editor - the editor will auto-focus, but it will also raise an onChange event - even though the editor state has not changed.

The current behavior

An onChange event is being raised even though there is no change to editorState

The expected behavior

There should be no onChange event when the document / editor is loaded (for example when a user is simply opening a document in the application)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    all-platforms-bugcontribution-weekIssues that are good to be picked up for the contribution weekgood first issueGood for newcomersotherFeature not covered by the rest of the labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions