fix(remote-desktop): release held keys on focus loss (#1498)

This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-09-30 09:45:29 -05:00
1 parent a4a4d4f27b
commit fb28cd1f21
2 files changed
+108 -12

No files matched your search

@@ -345,9 +345,9 @@ export const GuacamoleDisplay = forwardRef<
(hasKeyboardFocusRef.current || displayIsFocused);
if (!shouldCaptureInput) {
keyboard.reset();
keyboard.onkeydown = null;
keyboard.onkeyup = null;
keyboard.reset();
return;
}
@@ -366,17 +366,8 @@ export const GuacamoleDisplay = forwardRef<
};
keyboard.onkeyup = (keysym: number) => {
if (!clientRef.current) return;
if (!isVisible || !windowFocusedRef.current) return;
const activeDisplay = displayElementRef.current;
const stillFocused =
!!activeDisplay &&
typeof document !== "undefined" &&
document.activeElement === activeDisplay;
if (!hasKeyboardFocusRef.current && !stillFocused) return;
clientRef.current.sendKeyEvent(0, keysym);
// Focus loss must still release keys already sent to the remote host.
clientRef.current?.sendKeyEvent(0, keysym);
};
}, [isVisible]);