From 9b0a289cc8ce0ac5fe3ddb7837ccfe5d0a1293f7 Mon Sep 17 00:00:00 2001 From: drelich Date: Tue, 17 Mar 2026 00:22:29 +0100 Subject: [PATCH] Improve note deletion UX with double-click confirmation - Replaced confusing browser confirm() dialog with double-click to delete - First click highlights delete button in red (confirmation state) - Second click within 3 seconds actually deletes the note - Visual feedback with red background on confirmation state - Tooltip changes to 'Click again to confirm deletion' - Removed debug logging from delete handlers - Much clearer and more intuitive deletion flow --- src/App.tsx | 12 +----------- src/components/NotesList.tsx | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 2009fac..41a32af 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -147,20 +147,10 @@ function App() { }; const handleDeleteNote = async (note: Note) => { - console.log('handleDeleteNote called for note:', note.id, note.title); - if (!api) { - console.log('No API instance'); - return; - } - - const confirmed = confirm(`Delete "${note.title}"?`); - console.log('User confirmed deletion:', confirmed); - if (!confirmed) return; + if (!api) return; try { - console.log('Calling API deleteNote...'); await api.deleteNote(note.id); - console.log('Note deleted successfully, updating state...'); setNotes(notes.filter(n => n.id !== note.id)); if (selectedNoteId === note.id) { setSelectedNoteId(notes[0]?.id || null); diff --git a/src/components/NotesList.tsx b/src/components/NotesList.tsx index f9412cb..c0e01e8 100644 --- a/src/components/NotesList.tsx +++ b/src/components/NotesList.tsx @@ -35,12 +35,28 @@ export function NotesList({ onToggleFavorites, }: NotesListProps) { const [isSyncing, setIsSyncing] = React.useState(false); + const [deleteClickedId, setDeleteClickedId] = React.useState(null); const handleSync = async () => { setIsSyncing(true); await onSync(); setTimeout(() => setIsSyncing(false), 500); }; + + const handleDeleteClick = (note: Note, e: React.MouseEvent) => { + e.stopPropagation(); + + if (deleteClickedId === note.id) { + // Second click - actually delete + onDeleteNote(note); + setDeleteClickedId(null); + } else { + // First click - show confirmation state + setDeleteClickedId(note.id); + // Reset after 3 seconds + setTimeout(() => setDeleteClickedId(null), 3000); + } + }; const formatDate = (timestamp: number) => { const date = new Date(timestamp * 1000); const now = new Date(); @@ -145,14 +161,13 @@ export function NotesList({