From 3b756648c58243c0a0958d067ee123df8cbb2532 Mon Sep 17 00:00:00 2001 From: r-zakarya <82443831+r-zakarya@users.noreply.github.com> Date: Sun, 12 Jul 2026 19:52:56 +0100 Subject: [PATCH] fix(slideover): discard-confirm on new->new switch (Ctrl+Shift+A) Opening a fresh new entry while a dirty unsaved one was open skipped the discard prompt: both soState.id and id are null, so soState.id !== id was false and "switching" never triggered. Existing->anything worked (ids differ). OR in the null/null case. Co-Authored-By: Claude Opus 4.8 --- js/app.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/app.js b/js/app.js index 9539e39..93fac4c 100644 --- a/js/app.js +++ b/js/app.js @@ -3829,9 +3829,12 @@ async function openSlideOver(id, opts) { // changes would silently drop them — gate on the same confirm dialog // used by close paths. Only fires when the panel is already open AND // we're actually moving to a different target. + // A "switch" = the panel is open on a different target. soState.id !== id + // catches every cross-id case EXCEPT new→new (both ids null), which is + // still a real switch (a dirty unsaved new entry replaced by a fresh one, + // e.g. Ctrl+Shift+A) — so OR that case in explicitly. const switching = $('#slideover').classList.contains('is-open') && - soState && (soState.id !== id) && - !(isNew && soState.id == null && soState.id === id); + soState && (soState.id !== id || (id == null && soState.id == null)); if (switching && state.confirmOnUnsaved && isSoDirty()) { const ok = await confirmDialog({ title: 'Discard unsaved changes?',