From e88dbf3ec83106360a54da7cfa9877da1ae95f70 Mon Sep 17 00:00:00 2001 From: r-zakarya <82443831+r-zakarya@users.noreply.github.com> Date: Sat, 25 Jul 2026 23:25:28 +0100 Subject: [PATCH] fix(quick-search): Esc from the tray now closes AND returns to the tray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs in the same flow, both on the tray-originated path. 1. Esc did nothing until the search box was clicked: after the tray restore the WebView2 child does not hold the OS keyboard focus, so no keystroke reached the page at all — a DOM .focus() cannot fix that. Both quick-search entry points now call WebBrowser.SetFocus after restoring. 2. Esc closed the modal but left the app on screen. In fill mode closeQuickSearchModal fires cancelAutofill and then minimizeToTray, and two back-to-back window.location.href assignments COALESCE — the minimise was dropped. The copy path was unaffected because it never calls cancelAutofill, which is why this only showed up here. Deferred by a setTimeout(0), the same remedy CLAUDE.md already documents for quickunlock/store + pin/clear. Co-Authored-By: Claude Opus 4.8 --- delphi-backend/UMainForm.pas | 6 ++++++ js/app.overlays.js | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/delphi-backend/UMainForm.pas b/delphi-backend/UMainForm.pas index 2c6092b..ca06c3b 100644 --- a/delphi-backend/UMainForm.pas +++ b/delphi-backend/UMainForm.pas @@ -411,6 +411,11 @@ begin // stays open after the modal closes. LWasHidden := not Self.Visible; RestoreWindowFromTray; + // The window is back but the WebView2 child does NOT hold the keyboard + // focus, so nothing typed reaches the page — Esc did nothing until the user + // clicked the search box. DOM .focus() alone cannot fix that: the OS-level + // focus has to be on the browser control first. + WebBrowser.SetFocus; LWasHiddenJs := BoolToStr(LWasHidden, True).ToLower; // Second arg forFill=true tells JS to SendInput on pick instead of copy. WebBrowser.ExecuteJavaScript( @@ -435,6 +440,7 @@ begin // (taskbar) does NOT count — see BridgeQuickSearchHotkey. LWasHidden := not Self.Visible; RestoreWindowFromTray; + WebBrowser.SetFocus; // see BridgeQuickSearchHotkey — keystrokes need it LWasHiddenJs := BoolToStr(LWasHidden, True).ToLower; WebBrowser.ExecuteJavaScript( 'if(window.Bridge&&typeof Bridge.openQuickSearch==="function")' + diff --git a/js/app.overlays.js b/js/app.overlays.js index 8d314d9..396e08a 100644 --- a/js/app.overlays.js +++ b/js/app.overlays.js @@ -502,7 +502,12 @@ function closeQuickSearchModal(keepClipboard) { if (quickSearchHideAfter) { quickSearchHideAfter = false; if (Bridge.active && typeof Bridge.minimizeToTray === 'function') - Bridge.minimizeToTray(!!keepClipboard); + // Deferred: in fill mode the cancelAutofill above already fired a + // cmd:// navigation, and two back-to-back window.location.href + // assignments COALESCE — only one survives, so the minimise was + // silently dropped and the app stayed on screen. Same pitfall as + // the quickunlock/store + pin/clear pair in doChangeMasterPassword. + setTimeout(() => Bridge.minimizeToTray(!!keepClipboard), 0); } }