Repository navigation
fix(note): stop destroying the Tiptap editor manually - #55
Merged
Merged
Conversation
NoteEditor registered a cleanup effect that called editor.destroy() on unmount, but @tiptap/react v3's useEditor already owns the editor lifecycle. Under React StrictMode the effect runs mount → cleanup → mount, so the manual destroy left the second mount with an already destroyed instance: the content-sync effect then read editor.storage.markdown as undefined, threw, and—with no error boundary—unmounted the whole React tree (blank window). This surfaced on "Add to Note" in chat because #15 made that path open the note editor, which mounts NoteEditor for the first time. Remove the manual destroy and let useEditor manage it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes the blank window that appears when clicking Add to Note in a chat while running the app in development.
Why?
NoteEditorregistered a cleanup effect that callededitor.destroy()on unmount, but@tiptap/reactv3'suseEditoralready owns the editor lifecycle. Under React StrictMode (dev), effects runmount → cleanup → mount, so the second mount received an already destroyed instance; the content-sync effect then readeditor.storage.markdown.getMarkdown()and threw. The renderer has no error boundary, so React unmounted the entire tree and the window went blank.Production builds do not double-invoke effects, which is why the packaged app did not reproduce this.
This surfaced on Add to Note because #15 made that path open the note editor, mounting
NoteEditorfor the first time.Related issue
No open issue; reported from manual testing.
What changed?
editor.destroy()cleanup effect fromNoteEditorand letuseEditormanage teardown.How was this tested?
Reproduced and verified with Electron CDP against
npm run dev(StrictMode active):TypeError: Cannot read properties of undefined (reading 'getMarkdown')inside<NoteEditor>, anddocument.body.innerText.lengthdropped to0(blank window).npm run typecheck:webpasses.npm testpasses (49/49).npx prettier --check src/renderer/src/components/notebook/note/NoteEditor.tsxpasses.Screenshots / recordings
Not applicable (no visual change when working).
Checklist
npm run typecheckpasses.npm run buildpasses.Desktop / build changes