Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,35 @@ function createWindow() {
// Set up application menu
const menu = createMenu(mainWindow);
Menu.setApplicationMenu(menu);

// Enable native find-in-page functionality with keyboard shortcuts
let findActive = false;

mainWindow.webContents.on("before-input-event", (event, input) => {
// Handle Cmd/Ctrl+F to start find
if (input.type === "keyDown" && input.key === "f" && (input.control || input.meta)) {
event.preventDefault();
// Start find with empty string to show the find interface
mainWindow?.webContents.findInPage("");
findActive = true;
}
// Handle Escape to stop find
else if (input.type === "keyDown" && input.key === "Escape" && findActive) {
event.preventDefault();
mainWindow?.webContents.stopFindInPage("clearSelection");
findActive = false;
}
// Handle Enter for find next (when find is active)
else if (input.type === "keyDown" && input.key === "Enter" && findActive && !input.shift) {
event.preventDefault();
mainWindow?.webContents.findInPage("", { forward: true, findNext: true });
}
// Handle Shift+Enter for find previous (when find is active)
else if (input.type === "keyDown" && input.key === "Enter" && findActive && input.shift) {
event.preventDefault();
mainWindow?.webContents.findInPage("", { forward: false, findNext: true });
Comment on lines +159 to +184

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Find shortcut never gathers search text and hijacks Enter

The new before-input-event handler sets findActive on every Cmd/Ctrl+F and then preventDefaults any subsequent Enter press while findActive is true, routing it to webContents.findInPage("", {findNext:true}). Electron does not show a native find UI and an empty string uses the previous selection, so most users never enter a search term and nothing is found. After a single Ctrl+F, the window effectively loses all Enter behaviour (e.g. submitting forms or triggering buttons) until Escape is pressed, because the handler intercepts the key even though no search is in progress. The feature therefore both fails to provide “find in page” and breaks normal keyboard interaction.

Useful? React with 👍 / 👎.

}
});
}

// App event handlers
Expand Down
50 changes: 50 additions & 0 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,31 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
{ role: "delete" as const },
{ role: "selectAll" as const },
{ type: "separator" as const },
{
label: "Find",
accelerator: "Cmd+F",
click: () => {
// Start find with empty string to show find interface
mainWindow.webContents.findInPage("");
},
},
{
label: "Find Next",
accelerator: "Cmd+G",
click: () => {
// Find next occurrence
mainWindow.webContents.findInPage("", { forward: true, findNext: true });
},
},
{
label: "Find Previous",
accelerator: "Cmd+Shift+G",
click: () => {
// Find previous occurrence
mainWindow.webContents.findInPage("", { forward: false, findNext: true });
},
},
{ type: "separator" as const },
{
label: "Speech",
submenu: [
Expand All @@ -92,6 +117,31 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
{ role: "delete" as const },
{ type: "separator" as const },
{ role: "selectAll" as const },
{ type: "separator" as const },
{
label: "Find",
accelerator: "Ctrl+F",
click: () => {
// Start find with empty string to show find interface
mainWindow.webContents.findInPage("");
},
},
{
label: "Find Next",
accelerator: "F3",
click: () => {
// Find next occurrence
mainWindow.webContents.findInPage("", { forward: true, findNext: true });
},
},
{
label: "Find Previous",
accelerator: "Shift+F3",
click: () => {
// Find previous occurrence
mainWindow.webContents.findInPage("", { forward: false, findNext: true });
},
},
]),
],
},
Expand Down