From 93e2a87fa6b54aac14d8331996b5859de728b5ff Mon Sep 17 00:00:00 2001 From: drelich Date: Tue, 17 Mar 2026 09:29:53 +0100 Subject: [PATCH] Fix delete button to respect unsaved changes lock - Prevent delete button from working when there are unsaved changes on a different note - Delete button now checks hasUnsavedChanges before allowing deletion - Only the currently selected note can be deleted when it has unsaved changes - Prevents accidental deletion of other notes when locked --- src/components/NotesList.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/NotesList.tsx b/src/components/NotesList.tsx index a0680cb..187758c 100644 --- a/src/components/NotesList.tsx +++ b/src/components/NotesList.tsx @@ -48,6 +48,11 @@ export function NotesList({ const handleDeleteClick = (note: Note, e: React.MouseEvent) => { e.stopPropagation(); + // Prevent deletion if there are unsaved changes on a different note + if (hasUnsavedChanges && note.id !== selectedNoteId) { + return; + } + if (deleteClickedId === note.id) { // Second click - actually delete onDeleteNote(note);