fix(autofill): refusing a request must not move any window

The busy guard cancelled through the path that hands the foreground back to the captured target. During an export that pushed the native Save dialog behind the other application, leaving the app disabled by a modal the user could no longer find. refocus=0 separates refusing a request from ending a user interaction.
This commit is contained in:
r-zakarya
2026-08-01 18:30:00 +01:00
parent 03cc7adc25
commit 42d2d6fda5
4 changed files with 25 additions and 7 deletions
+7 -2
View File
@@ -1093,13 +1093,18 @@ begin
// foreground process at that moment, so plain SetForegroundWindow works.
else if ACmd = 'autofill/cancel' then
begin
if FAutofillTargetHWND <> 0 then
// refocus=0 — JS is REFUSING the request, not ending a user interaction:
// nothing must move on screen. During an export a native Save dialog owns
// the foreground, and pushing it behind leaves the app disabled by a modal
// the user can no longer find.
var LRefocus := GetParam('refocus') <> '0';
if LRefocus and (FAutofillTargetHWND <> 0) then
SetForegroundWindow(FAutofillTargetHWND);
FAutofillTargetHWND := 0;
// The window only came out of the tray to show the picker, so dismissing it
// puts it back — same as quick-search, which hides on Esc too. Done after
// handing focus to the target above.
if FAutofillHotkeyWasHidden then
if FAutofillHotkeyWasHidden and LRefocus then
begin
FAutofillHotkeyWasHidden := False;
// Foreground already handed to the target above.