Skip to content

Commit 0e15679

Browse files
authored
Desktop: Fix editor plugins receiving stale note body during navigation (#14513)
1 parent f2b558c commit 0e15679

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/app-desktop/gui/NoteEditor/utils/useConnectToEditorPlugin.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,18 @@ const useConnectToEditorPlugin = ({
9595
}, [activeEditorView, editorPluginHandler]);
9696

9797
const formNoteBody = formNote.body;
98+
const formNoteId = formNote.id;
9899
useEffect(() => {
100+
// Don't emit updates when formNote hasn't loaded the current note yet.
101+
// This can happen during note navigation when effectiveNoteId updates
102+
// immediately but formNote still contains the previous note's data.
103+
if (formNoteId !== effectiveNoteId) return;
104+
99105
editorPluginHandler.emitUpdate({
100106
noteId: effectiveNoteId,
101107
newBody: formNoteBody,
102108
}, shownEditorViewIds);
103-
}, [effectiveNoteId, formNoteBody, editorPluginHandler, shownEditorViewIds]);
109+
}, [effectiveNoteId, formNoteId, formNoteBody, editorPluginHandler, shownEditorViewIds]);
104110
};
105111

106112
export default useConnectToEditorPlugin;

0 commit comments

Comments
 (0)