From 813d756b9c3cd85cdb00f819d13f87c8c09fa88c Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Thu, 11 Jun 2026 20:42:28 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(editor-canvas):=20re-check?= =?UTF-8?q?=20editor=20init=20state=20before=20subscribing=20(#15686)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Claude Fable 5 --- src/features/EditorCanvas/DiffAllToolbar.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/features/EditorCanvas/DiffAllToolbar.tsx b/src/features/EditorCanvas/DiffAllToolbar.tsx index 0e2376fc70..1db6e4da55 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); };