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
This commit is contained in:
drelich
2026-03-17 09:29:53 +01:00
parent 2d1cc4baf0
commit 93e2a87fa6

View File

@@ -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);