diff --git a/delphi-backend/Source/PM.Bridge.pas b/delphi-backend/Source/PM.Bridge.pas index 402b730..7841828 100644 --- a/delphi-backend/Source/PM.Bridge.pas +++ b/delphi-backend/Source/PM.Bridge.pas @@ -669,6 +669,7 @@ end; procedure TPMBridge.RestoreFromTray; var LFormHwnd, LAppHwnd: HWND; + LWasTrayHidden: Boolean; begin // Tray icon stays in the tray — we only show the window again. LFormHwnd := MainFormHWND(FMainForm); @@ -684,6 +685,10 @@ begin Exit; end; + // Captured BEFORE Show flips Visible: tray-hidden (Hide'd by + // MinimizeToTray) vs merely taskbar-minimised (Visible but iconic). + LWasTrayHidden := not FMainForm.Visible; + // Reverse order: show the app proxy first so the taskbar entry comes back, // then show and foreground the form. if LAppHwnd <> 0 then @@ -697,7 +702,11 @@ begin // window). Unconditional SW_RESTORE would un-maximise a maximised // window — surprising for the user who pressed Ctrl+Shift+A / +L / // clicked the tray. - if FHasSavedPlacement then + // Replay the snapshot ONLY for a genuine tray return (window was hidden — + // the exact state MinimizeToTray created). A merely taskbar-minimised + // window restores via Windows' own placement memory below; replaying our + // older snapshot would teleport it to wherever it sat at the LAST tray-hide. + if FHasSavedPlacement and LWasTrayHidden then begin // showCmd governs whether the window comes back maximised or normal; // it's what SW_RESTORE clobbers. We force it ourselves. Captured while @@ -1325,6 +1334,9 @@ begin ClearFieldIfWanted; SendUnicodeString(AUsername); Sleep(200); + // Real-VK send: a physically held Shift here turns Tab into Shift+Tab — + // focus moves BACKWARD and the password lands in the username field. + ForceReleaseModifiers; SendVKey(VK_TAB); Sleep(200); ClearFieldIfWanted; diff --git a/js/app.js b/js/app.js index 42b3f84..a17d1c9 100644 --- a/js/app.js +++ b/js/app.js @@ -7222,6 +7222,10 @@ async function init() { if (e.key !== 'Escape') return; if (!$('#slideover').classList.contains('is-open')) return; if (document.querySelector('.modal:not(.is-hidden)')) return; + // Command palette is .cmd-palette, not .modal — it sits on top of + // the editor, so its Esc must close IT (bubble handler), not pop + // the editor's discard-confirm underneath. + if (!$('#cmdPalette').classList.contains('is-hidden')) return; // Settings panel takes priority — when both Settings AND the // editor are open, the first Esc should close Settings (the // thing the user just opened on top), the second Esc handles @@ -7912,13 +7916,27 @@ async function init() { closeHistoryModal(); return; } - closePalette(); - requestCloseSlideOver(); - closeEntryModal(); - closeGen(); - // If nothing else needed dismissing and there's an active - // selection, clear it. Replaces the "click empty space to - // deselect" path that the marquee provided. + // ONE surface per keystroke, topmost first — closing several at + // once meant "Esc closes the palette AND pops the editor's + // discard prompt" (same class as the quick-search Esc bug). + if (!$('#cmdPalette').classList.contains('is-hidden')) { + closePalette(); + return; + } + if (!$('#entryModal').classList.contains('is-hidden')) { + closeEntryModal(); + return; + } + if (!$('#genModal').classList.contains('is-hidden')) { + closeGen(); + return; + } + if ($('#slideover').classList.contains('is-open')) { + requestCloseSlideOver(); + return; + } + // Nothing else needed dismissing — clear an active selection. + // Replaces the "click empty space to deselect" marquee path. if (state.checked.size > 0) { state.checked.clear(); renderGrid();