Repository navigation
fix(note): save the title from the shortcut and rename through the store - #51
Merged
Merged
Conversation
Renaming a note was unreliable (issue #25): - The `Ctrl/Cmd+S` "Save Note" shortcut only fired when the Tiptap body was focused (`editor.isFocused`). Editing the title field and pressing the shortcut did nothing, so the name looked saved but never reached the DB. - The context-menu rename wrote through `window.api.updateNote` and relied on the optional `onRefresh` reload to make the list show the new title, so the item store could stay stale until the next `loadItems` (e.g. after creating a note). Move the shortcut listener up to `NoteEditorPanel`, which owns both the title input and the body, and save whenever focus is anywhere inside the panel. Drop the now-unused `onSave` prop from `NoteEditor`. Route note renames through `useItemStore.updateNote` so the list updates from the same store the editor uses; keep `onRefresh` for the other item types. Verified against a running build (Electron + CDP): the shortcut saves with the title field focused, and both the editor save and the context-menu rename land in the DB and in the list immediately.
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.
Closes #25.
Problem
Renaming a note could appear to do nothing until the list happened to reload:
Ctrl/Cmd+S"Save Note" shortcut only fired while the Tiptap body wasfocused (
editor.isFocusedinNoteEditor). Changing the title in theheader field and pressing the shortcut silently did nothing — the field kept
the typed value, so it looked saved, but nothing was written.
window.api.updateNotedirectly andonly relied on the optional
onRefreshprop to re-fetch. The item store wasleft stale until the next
loadItems— which is exactly the "create a newnote and it finally updates" symptom.
Fix
shortcut:save-notelistener fromNoteEditortoNoteEditorPanel, which owns both the title input and the body, and savewhenever focus is inside the panel. Remove the now-unused
onSaveprop.useItemStore.updateNoteso the list and theeditor read the same store;
onRefreshstill runs and still coversmind-map / quiz / anki renames.
Verification
Ran the built app (Electron) against a throwaway
--user-data-dirwith aseeded notebook, driven over the DevTools protocol:
shortcut:save-note→ the new titleis written to
notesand shown in the list (previously nothing happened)Static checks:
npm run typecheck(node/web/test),npm run lint,npm run check:design,npm test(22 pass),npx electron-vite build.Not verified: manual clicking on a physical desktop session (interaction was
simulated via CDP against the real renderer).