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.
This commit is contained in:
beyondkmp 2025-10-17 15:07:19 +08:00 committed by GitHub
parent 2243bb2862
commit c4e0a6acfe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,