A local-first personal finance app
:electron: Prevent keyboard shortcuts modal when entering shortcut into editable field (#3389)
Michael Clark407e3143eb29
diff --git a/packages/desktop-client/src/index.tsx b/packages/desktop-client/src/index.tsxindex 0d64a88cb5..c6800e7047 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-definitionsinterface 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.tsindex 4c44c30ce2..5cd99b82ea 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.mdnew file mode 100644index 0000000000..93fff21f0f--- /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.