From c4e0a6acfe2d904dfbc8ec6b83c22bd1cb6b2408 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Fri, 17 Oct 2025 15:07:19 +0800 Subject: [PATCH] fix: prevent default behavior for Cmd/Ctrl+F in WebviewService (#10783) fix: prevent default behavior for Cmd/Ctrl+F in WebviewService (#10800) Updated the keyboard handler in WebviewService to always prevent the default action for the Cmd/Ctrl+F shortcut, ensuring it overrides the guest page's native find dialog. This change allows the renderer to manage the behavior of Escape and Enter keys based on the visibility of the search bar. --- src/main/services/WebviewService.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/services/WebviewService.ts b/src/main/services/WebviewService.ts index 1b60cc6643..fb2049de74 100644 --- a/src/main/services/WebviewService.ts +++ b/src/main/services/WebviewService.ts @@ -60,15 +60,20 @@ const attachKeyboardHandler = (contents: Electron.WebContents) => { if (!isFindShortcut && !isEscape && !isEnter) { return } - // Prevent default to override the guest page's native find dialog - // and keep shortcuts routed to our custom search overlay - event.preventDefault() const host = contents.hostWebContents if (!host || host.isDestroyed()) { return } + // Always prevent Cmd/Ctrl+F to override the guest page's native find dialog + if (isFindShortcut) { + event.preventDefault() + } + + // Send the hotkey event to the renderer + // The renderer will decide whether to preventDefault for Escape and Enter + // based on whether the search bar is visible host.send(IpcChannel.Webview_SearchHotkey, { webviewId: contents.id, key,