fix(trash): warn about unsaved edits when delete asks nothing

With askBeforeDelete off, clicking ✕ on the entry being edited trashed it
and closed the editor with no prompt whatsoever — a misclick cost the edits
silently. That path now runs the discard gate (no-op unless dirty). When
askBeforeDelete is on, its own confirm still stands alone: one modal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-07-22 23:09:15 +01:00
parent 4c2287fd35
commit 4b9ffaab62
+6
View File
@@ -5286,6 +5286,12 @@ async function deleteEntry(id) {
danger: true, danger: true,
}); });
if (!ok) return; if (!ok) return;
} else if (soState && soState.id === id) {
// No delete confirmation configured: a misclick on ✕ would trash the
// entry AND drop the edits in the open editor with no warning at all.
// The discard gate stands in for it (it no-ops when nothing is dirty).
// Skipped when askBeforeDelete already asked — one modal is enough.
if (!(await requestCloseSlideOver())) return;
} }
try { try {
await api('/entries/' + id, { method: 'DELETE', headers: authHeaders() }); await api('/entries/' + id, { method: 'DELETE', headers: authHeaders() });