facebook / facebook/lexical

Several react apps at the same page causing error unable to find an active editor state

Open
#5,224 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 16h
Merged PRs (30d)
61

Description

The problem occur when several react apps with editors are used at the same page.

The first react app that is getting focus works as expected no matter which app it is, but as soon as another app is getting focus an error occur that lexical is unable to find an active editor state. The first app editor is still working as excepted (sometimes).

Lexical version: 0.12.2

```
Uncaught Error: Unable to find an active editor state. State helpers or node methods can only be used synchronously during the callback of editor.update() or editorState.read().
at getActiveEditorState (Lexical.dev.js:7379:1)
at $getNodeByKey (Lexical.dev.js:721:1)
at ParagraphNode.getLatest (Lexical.dev.js:4090:1)
at ParagraphNode.getParent (Lexical.dev.js:3690:1)
at ParagraphNode.getIndexWithinParent (Lexical.dev.js:3664:1)
at internalResolveSelectionPoint (Lexical.dev.js:6682:1)
at internalResolveSelectionPoints (Lexical.dev.js:6787:1)
at internalCreateRangeSelection (Lexical.dev.js:6898:1)
at internalCreateSelection (Lexical.dev.js:6851:1)
at beginUpdate (Lexical.dev.js:8008:1)
```
Not sure if this is a bug? I have tried to use unique lexical namespaces for the apps, but it doesn't make any sense.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with several React apps containing editors, using the reported Lexical version 0.12.2. Trace the reported stack from beginUpdate through internalCreateSelection and getActiveEditorState in Lexical.dev.js, then compare behavior when focus moves between editors. Done means the editors can change focus without the active editor state error.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.