fix(autofill): return to the tray after picking in the multi-match picker

Only the quick-search path captured whether the window was tray-hidden and fed
it back as hide_after; JS never sends that parameter from the autofill picker,
so Ctrl+Shift+L pulled the window out of the tray and left it on the desktop.

Capture it in BridgeAutofillRequest instead, when the hotkey fires — by execute
time the picker has already restored the window and the state is gone. Same
rule as quick-search: tray-hidden only, a taskbar-minimised window is not sent
to the tray it never came from.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-07-27 21:03:57 +01:00
parent e98acabbbd
commit 3c84bdca49
2 changed files with 19 additions and 1 deletions
+13 -1
View File
@@ -120,6 +120,11 @@ type
// SendInput because Win10/11 anti-focus-stealing rules then refuse to
// hand focus to the target window.
FAutofillPendingHide: Boolean;
// Same idea for the Ctrl+Shift+L/P/T hotkeys: captured when the hotkey
// fires, because the multi-match picker pulls the window out of the tray
// before the user picks, so by execute time the state is already lost.
// JS never sends hide_after on this path — only quick-search does.
FAutofillHotkeyWasHidden: Boolean;
// True when the pending autofill should type ONLY the username (quick
// search "autofill username" — right-click / Shift+Enter in fill mode).
FAutofillPendingUserOnly: Boolean;
@@ -1056,7 +1061,8 @@ begin
FAutofillPendingUser := GetParam('username');
FAutofillPendingPass := GetParam('password');
FAutofillPendingHWND := FAutofillTargetHWND;
FAutofillPendingHide := GetParam('hide_after') = '1';
FAutofillPendingHide := (GetParam('hide_after') = '1') or FAutofillHotkeyWasHidden;
FAutofillHotkeyWasHidden := False;
FAutofillPendingUserOnly := GetParam('field') = 'user';
FAutofillPendingClear := GetParam('clear') <> '0'; // absent = ON
FAutofillPendingNotify := GetParam('notify') <> '0'; // absent = ON
@@ -1081,6 +1087,9 @@ begin
if FAutofillTargetHWND <> 0 then
SetForegroundWindow(FAutofillTargetHWND);
FAutofillTargetHWND := 0;
// Cancelled: the window stays wherever the user left it, and the captured
// state must not leak into the next hotkey.
FAutofillHotkeyWasHidden := False;
LogLine('Autofill cancelled (no match or dismissed)');
end
@@ -1775,6 +1784,9 @@ var
begin
if not FServer.Active then Exit;
FAutofillTargetHWND := ATargetHWND;
// Tray-hidden only, like the quick-search path: a window merely minimised to
// the taskbar must not come back as a tray icon it never was.
FAutofillHotkeyWasHidden := not Self.Visible;
// Escape the title for safe injection into a JS string literal.
LTitle := ATitle;