Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(editor-canvas): re-check editor init state before subscribing (#15686)

Arvin Xu813d756b9c3c
diff --git a/src/features/EditorCanvas/DiffAllToolbar.tsx b/src/features/EditorCanvas/DiffAllToolbar.tsx
index 0e2376fc704..1db6e4da55b 100644
--- a/src/features/EditorCanvas/DiffAllToolbar.tsx
+++ b/src/features/EditorCanvas/DiffAllToolbar.tsx
@@ -42,6 +42,14 @@ const useIsEditorInit = (editor?: IEditor) => {
useEffect(() => {
if (!editor) return;
+ // The editor may have initialized between render and this effect
+ // (the Editor canvas mounts earlier and emits 'initialized' synchronously),
+ // so re-check before subscribing to avoid missing the event forever.
+ if (editor.getLexicalEditor()) {
+ setEditInit(true);
+ return;
+ }
+
const onInit = () => {
setEditInit(true);
};