Skip to content
Snippets Groups Projects
Unverified Commit 407e3143 authored by Michael Clark's avatar Michael Clark Committed by GitHub
Browse files

:electron: Prevent keyboard shortcuts modal when entering shortcut into editable field (#3389)

* check input element is focused on before triggering keyboard shortcuts modal

* release notes

* remove comment
parent ac90eb21
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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")',
);
}
},
......
---
category: Bugfix
authors: [MikesGlitch]
---
Prevent keyboard shortcuts modal launching when entering shortcut into editable field.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment