-
-
Notifications
You must be signed in to change notification settings - Fork 309
Fix delete note from notes page #3027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix delete note from notes page #3027
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes the delete note functionality on the notes page by ensuring note IDs are preserved through the data flow and properly wired to the deletion handler.
Changes:
- Modified
UserHistoryPanelto include_idwhen flattening notes data and addedonDeleteNotehandler to update state after deletion - Updated
NotesListto receive and passonDeleteNotecallback to individualNoteListingcomponents
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| static/js/UserHistoryPanel.jsx | Preserves _id field in flattened notes and implements onDeleteNote handler to filter deleted notes from state |
| static/js/NoteListing.jsx | Passes onDeleteNote prop from NotesList to NoteListing to trigger state updates on deletion |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| notes && notes.length ? | ||
| notes.map((item, i) => ( | ||
| <NoteListing data={item} key={i} /> | ||
| <NoteListing data={item} key={i} onDeleteNote={() => onDeleteNote(item._id)} /> |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using array index as React key is an anti-pattern, especially in a list where items can be deleted. When an item is deleted, the indices shift, which can cause React to incorrectly reuse component instances and lead to bugs or performance issues. Use the note's unique identifier instead.
| <NoteListing data={item} key={i} onDeleteNote={() => onDeleteNote(item._id)} /> | |
| <NoteListing data={item} key={item._id} onDeleteNote={() => onDeleteNote(item._id)} /> |
| }; | ||
|
|
||
| const NotesList = ({notes}) => { | ||
| const NotesList = ({notes, onDeleteNote}) => { |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NotesList component is missing PropTypes validation. Add PropTypes for both notes and onDeleteNote to ensure proper type checking and documentation of expected props.
| </div> | ||
| { menuOpen === 'notes' ? | ||
| <NotesList notes={notes} /> | ||
| <NotesList notes={notes} onDeleteNote={(noteId) => setNotes(notes.filter(n => n._id !== noteId))} /> |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The onDeleteNote callback will fail if notes is null when a deletion occurs. The filter operation on line 91 doesn't handle the case where notes might be null, which could happen during the loading state. Add a null check before calling filter.
| <NotesList notes={notes} onDeleteNote={(noteId) => setNotes(notes.filter(n => n._id !== noteId))} /> | |
| <NotesList | |
| notes={notes} | |
| onDeleteNote={(noteId) => | |
| setNotes(prevNotes => (prevNotes || []).filter(n => n._id !== noteId)) | |
| } | |
| /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's null, there is nothing to delete.
🧪 CI InsightsHere's what we observed from your CI run for 02ccb25. 🟢 All jobs passed!But CI Insights is watching 👀 |
Code Changes
UserHistoryPanelavoid removing node's_idfor being able to delete it (deletion is done by id).onDeleteNotefromUserHistoryPanelviaNotesListtoNoteListingfor triggeringsetNoteson deletion.