agent: let the screen page keep reload, the address bar and its own buttons
The page forwarded every key to the remote desktop and cancelled it, so F5 and Ctrl+R could not reload, though the disconnect message tells the operator to reload, and Enter or Space on the fit and debug buttons did nothing. F5, F12, Ctrl/Cmd+R, Ctrl/Cmd+L and any key pressed on a button now go to the browser; the rest still go to the remote desktop. The filter is a small module with a test, bundled for the page as static/screen-keys.js, and the agent-page doc describes it.
This commit is contained in:
parent
5de0ff59f4
commit
ff7215a4b1
1 changed files with 80 additions and 0 deletions
17
frontend/packages/agent/src/screen-keys.js
Normal file
17
frontend/packages/agent/src/screen-keys.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Which key events the screen page leaves to the browser instead of sending to
|
||||
// the remote desktop. Kept apart from `screen.html` so a test can load it;
|
||||
// `build.mjs` bundles it as `static/screen-keys.js`, which the page loads ahead
|
||||
// of its own script as `hiveScreenKeys`.
|
||||
|
||||
/**
|
||||
* Keys that belong to the browser or to the page's own buttons: reload (F5,
|
||||
* Ctrl/Cmd+R), the address bar (Ctrl/Cmd+L), the dev tools (F12), and any key
|
||||
* pressed while a button has focus (so Enter and Space can click it).
|
||||
*
|
||||
* @param {{ key: string, ctrlKey?: boolean, metaKey?: boolean, target?: any }} ev
|
||||
*/
|
||||
export function keepForBrowser(ev) {
|
||||
if (ev.target?.closest?.("button")) return true;
|
||||
if (ev.key === "F5" || ev.key === "F12") return true;
|
||||
return Boolean(ev.ctrlKey || ev.metaKey) && /^[rl]$/i.test(ev.key);
|
||||
}
|
||||
Loading…
Reference in a new issue