Skip to content

fix(note): save the title from the shortcut and rename through the store - #51

Merged
mrsibe merged 1 commit into
mainfrom
fix/note-rename-save
Sep 24, 2026
Merged

mrsibe merged 1 commit into
mainfrom
fix/note-rename-save

Conversation

@mrsibe

@mrsibe mrsibe commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Closes #25.

Problem

Renaming a note could appear to do nothing until the list happened to reload:

  • The Ctrl/Cmd+S "Save Note" shortcut only fired while the Tiptap body was
    focused (editor.isFocused in NoteEditor). Changing the title in the
    header field and pressing the shortcut silently did nothing — the field kept
    the typed value, so it looked saved, but nothing was written.
  • The context-menu "Rename" action called window.api.updateNote directly and
    only relied on the optional onRefresh prop to re-fetch. The item store was
    left stale until the next loadItems — which is exactly the "create a new
    note and it finally updates" symptom.

Fix

  • Move the shortcut:save-note listener from NoteEditor to
    NoteEditorPanel, which owns both the title input and the body, and save
    whenever focus is inside the panel. Remove the now-unused onSave prop.
  • Route note renames through useItemStore.updateNote so the list and the
    editor read the same store; onRefresh still runs and still covers
    mind-map / quiz / anki renames.

Verification

Ran the built app (Electron) against a throwaway --user-data-dir with a
seeded notebook, driven over the DevTools protocol:

  • focus the title input, change it, fire shortcut:save-note → the new title
    is written to notes and shown in the list (previously nothing happened)
  • save from the focused editor body still works
  • context-menu rename → list updates immediately and the DB matches

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).

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.
@github-actions github-actions Bot added the bug Something isn't working label Sep 24, 2026
@mrsibe
mrsibe merged commit 0aba7d7 into main Sep 24, 2026
4 checks passed
@mrsibe
mrsibe deleted the fix/note-rename-save branch September 24, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

修改笔记名称的bug

1 participant