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:
@@ -3829,9 +3829,12 @@ async function openSlideOver(id, opts) {
|
|||||||
// changes would silently drop them — gate on the same confirm dialog
|
// changes would silently drop them — gate on the same confirm dialog
|
||||||
// used by close paths. Only fires when the panel is already open AND
|
// used by close paths. Only fires when the panel is already open AND
|
||||||
// we're actually moving to a different target.
|
// 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') &&
|
const switching = $('#slideover').classList.contains('is-open') &&
|
||||||
soState && (soState.id !== id) &&
|
soState && (soState.id !== id || (id == null && soState.id == null));
|
||||||
!(isNew && soState.id == null && soState.id === id);
|
|
||||||
if (switching && state.confirmOnUnsaved && isSoDirty()) {
|
if (switching && state.confirmOnUnsaved && isSoDirty()) {
|
||||||
const ok = await confirmDialog({
|
const ok = await confirmDialog({
|
||||||
title: 'Discard unsaved changes?',
|
title: 'Discard unsaved changes?',
|
||||||
|
|||||||
Reference in New Issue
Block a user