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 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-07-12 19:52:56 +01:00
parent 2c7f6188e3
commit 3b756648c5
+5 -2
View File
@@ -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?',