Repository navigation
fix(desktop): clicking inside the in-app browser closes open host menus #23141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
59dfa1b
51692b7
0804c97
a6b74d5
cf3b6cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,16 +184,24 @@ export function HostedBrowserWebview(props: { | |
| if (!disposed) remountCrashedWebview(); | ||
| }, recovery.delayMs); | ||
| }; | ||
| // Guest clicks only emit focus here; replay pointerdown to dismiss host popups. | ||
| // Guest clicks never reach this document, so replay a pointerdown to dismiss host popups. | ||
| // The guest preload reports each press, since the guest does not always take focus. | ||
| const dismissHostPopups = () => { | ||
| webview.dispatchEvent( | ||
| new PointerEvent("pointerdown", { bubbles: true, pointerType: "mouse" }), | ||
| ); | ||
| }; | ||
| const guestPointerDown = (event: Event) => { | ||
| // Mirrors POINTER_DOWN_HOST_CHANNEL in apps/desktop/src/preview/GuestProtocol.ts. | ||
| if ((event as Event & { channel?: string }).channel === "preview:pointer-down") { | ||
| dismissHostPopups(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a regression test for dismissal without focus. The PR reports no unit test for this fix. Add a focused test that sends As per coding guidelines, “Logic, data, state, and protocol bugs get a failing test first.”
|
||
| } | ||
| }; | ||
| webview.addEventListener("did-attach", register); | ||
| webview.addEventListener("dom-ready", register); | ||
| webview.addEventListener("render-process-gone", recoverGuest); | ||
| webview.addEventListener("focus", dismissHostPopups); | ||
| webview.addEventListener("ipc-message", guestPointerDown); | ||
| register(); | ||
| return () => { | ||
| disposed = true; | ||
|
|
@@ -202,6 +210,7 @@ export function HostedBrowserWebview(props: { | |
| webview.removeEventListener("dom-ready", register); | ||
| webview.removeEventListener("render-process-gone", recoverGuest); | ||
| webview.removeEventListener("focus", dismissHostPopups); | ||
| webview.removeEventListener("ipc-message", guestPointerDown); | ||
| }; | ||
| }, [ | ||
| clientSettingsHydrated, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.