Skip to content

feat: add keyboard shortcuts for duplicate, delete, and empty-note navigation#86

Open
n00ki wants to merge 2 commits intoerictli:mainfrom
n00ki:feat/keyboard-shortcuts
Open

feat: add keyboard shortcuts for duplicate, delete, and empty-note navigation#86
n00ki wants to merge 2 commits intoerictli:mainfrom
n00ki:feat/keyboard-shortcuts

Conversation

@n00ki
Copy link

@n00ki n00ki commented Mar 5, 2026

  • Add Cmd+D to duplicate the current note (when not in editor/input)
  • Add Delete / Cmd+Backspace to delete the current note (from note list or empty editor)
  • Allow arrow key navigation between notes when the editor is focused on an empty note
  • Dispatch focus-note-list after arrow navigation so the note list reflects keyboard focus

Implementation

  • All new shortcuts are centralized in the global keydown handler in App.tsx, consistent with existing shortcuts
  • Delete triggers a request-delete-note custom event, which NoteList.tsx listens for to open the confirmation dialog (same cross-component event pattern used by focus-note-list, toggle-source-mode, etc.)
  • Uses a currentNoteRef to read note content without adding currentNote to the effect dependency array, avoiding handler re-registration on every auto-save
  • Updated shortcuts reference in Settings and README

Summary by CodeRabbit

  • New Features

    • Added Cmd+D to duplicate the current note.
    • Added Delete and Cmd+Backspace to delete the current note.
    • Improved keyboard navigation: better ArrowUp/ArrowDown behavior, Enter focuses editor only when appropriate, and Escape returns focus to the note list.
  • UX

    • Added a delete confirmation dialog trigger for keyboard/context actions and new shortcuts listed in settings.

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 859bb117-d006-4fc1-8144-61432d58638d

📥 Commits

Reviewing files that changed from the base of the PR and between 85ec615 and cdc48f4.

📒 Files selected for processing (1)
  • README.md

📝 Walkthrough

Walkthrough

Adds keyboard shortcuts for duplicating and deleting notes, wires duplicateNote into App keyboard handling, adds an event-driven delete dialog trigger in NoteList, and documents the new shortcuts in ShortcutsSettingsSection and README.

Changes

Cohort / File(s) Summary
Keyboard shortcut handling
src/App.tsx
Adds Cmd+D duplicate and Delete/Cmd+Backspace delete handlers; introduces currentNoteRef and isEditorEmpty logic; adjusts Arrow/Enter/Escape navigation focus behavior; includes duplicateNote in effect deps.
Note deletion dialog integration
src/components/notes/NoteList.tsx
Adds openDeleteDialogForNote(noteId) helper, replaces inline delete with it in context menu, and listens for request-delete-note custom events to open the confirmation dialog.
Shortcuts UI & docs
src/components/settings/ShortcutsSettingsSection.tsx, README.md
Adds shortcut entries for Duplicate (mod+D) and Delete (Delete, mod+Backspace) to the settings UI and README keyboard-shortcuts table.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant App as App (keydown handler)
  participant NotesHook as Notes hook (duplicateNote)
  participant NoteList as NoteList (delete dialog)
  participant UI as Delete Confirm Dialog

  User->>App: press Cmd+D
  App->>NotesHook: duplicateNote(currentNoteRef.current)
  NotesHook-->>App: new note created (id)
  App->>UI: focus/selection updates

  User->>App: press Delete / Cmd+Backspace
  App->>NoteList: dispatch custom event "request-delete-note" with noteId
  NoteList->>NoteList: openDeleteDialogForNote(noteId)
  NoteList->>UI: show delete confirmation
  UI->>NoteList: confirm/delete -> perform deletion
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • erictli

Poem

🐰 Tap the keys, a duplicate springs bright,
A thump of Delete clears by moonlight.
I hop through code with nimble paws,
Shortcuts stitched with clever laws.
Hooray — quick notes, trimmed just right!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding keyboard shortcuts for duplicate, delete, and arrow navigation for notes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Around line 81-82: README's keyboard shortcuts table is missing the `Delete`
key entry that the Settings UI (ShortcutsSettingsSection.tsx) documents; update
the table to add a row for the `Delete` key with the same "Delete note"
description as `Cmd+Backspace` so the README matches the UI (add a line like |
`Delete` | Delete note | adjacent to the existing `Cmd+Backspace` row).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4a8b4834-11ba-4f99-ab8d-c2f84024faae

📥 Commits

Reviewing files that changed from the base of the PR and between 3331c1e and 85ec615.

📒 Files selected for processing (4)
  • README.md
  • src/App.tsx
  • src/components/notes/NoteList.tsx
  • src/components/settings/ShortcutsSettingsSection.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant