facebook / facebook/lexical

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

Open
#4,493 5 comments 12 reactions 0 assignees View on GitHub
all-platforms-bug contribution-week good first issue other
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 14h
Merged PRs (30d)
55

Description

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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.