diff --git a/packages/desktop-client/src/index.tsx b/packages/desktop-client/src/index.tsx index 0d64a88cb502ddb4664eda40f0896a83385664da..c6800e704733e61cc957d4b876faa575c49816a4 100644 --- a/packages/desktop-client/src/index.tsx +++ b/packages/desktop-client/src/index.tsx @@ -70,7 +70,7 @@ handleGlobalEvents(boundActions, store); declare global { // eslint-disable-next-line @typescript-eslint/consistent-type-definitions interface Window { - __actionsForMenu: BoundActions; + __actionsForMenu: BoundActions & { inputFocused: typeof inputFocused }; $send: typeof send; $query: typeof runQuery; @@ -78,8 +78,16 @@ declare global { } } +function inputFocused() { + return ( + window.document.activeElement.tagName === 'INPUT' || + window.document.activeElement.tagName === 'TEXTAREA' || + (window.document.activeElement as HTMLElement).isContentEditable + ); +} + // Expose this to the main process to menu items can access it -window.__actionsForMenu = boundActions; +window.__actionsForMenu = { ...boundActions, inputFocused }; // Expose send for fun! window.$send = send; diff --git a/packages/desktop-electron/menu.ts b/packages/desktop-electron/menu.ts index 4c44c30ce211565974ff90468fdc2e9e7010ede5..5cd99b82ea24b7f60d642a5810542e01d970dc1c 100644 --- a/packages/desktop-electron/menu.ts +++ b/packages/desktop-electron/menu.ts @@ -179,7 +179,7 @@ export function getMenu( click: function (_menuItem, focusedWin) { if (focusedWin) { focusedWin.webContents.executeJavaScript( - 'window.__actionsForMenu && window.__actionsForMenu.pushModal("keyboard-shortcuts")', + 'window.__actionsForMenu && !window.__actionsForMenu.inputFocused() && window.__actionsForMenu.pushModal("keyboard-shortcuts")', ); } }, diff --git a/upcoming-release-notes/3389.md b/upcoming-release-notes/3389.md new file mode 100644 index 0000000000000000000000000000000000000000..93fff21f0f65c1113140b2a7248b0544d4ee2df3 --- /dev/null +++ b/upcoming-release-notes/3389.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [MikesGlitch] +--- + +Prevent keyboard shortcuts modal launching when entering shortcut into editable field.