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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user