This commit is contained in:
antelle 2021-05-29 16:22:45 +02:00
parent 40dd3637d7
commit 0ce5fc462a
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
3 changed files with 12 additions and 12 deletions

View File

@ -161,6 +161,7 @@
"no-else-return": "off",
"jest/valid-expect": "off",
"jest/expect-expect": "off",
"react-hooks/exhaustive-deps": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",

View File

@ -14,17 +14,6 @@ import { useModelWatcher } from 'util/ui/hooks';
export const AppMenuItem: FunctionComponent<{ item: MenuItem }> = ({ item }) => {
useModelWatcher(item);
useEffect(() => {
if (item.shortcut) {
const offs: Callback[] = [];
offs.push(KeyHandler.onKey(item.shortcut, selectItem, KeyHandler.SHORTCUT_OPT));
if (item.shortcut !== Keys.DOM_VK_C) {
offs.push(KeyHandler.onKey(item.shortcut, selectItem, KeyHandler.SHORTCUT_ACTION));
}
return () => offs.forEach((off) => off());
}
}, []);
const selectItem = () => {
if (item.active) {
return;
@ -38,6 +27,17 @@ export const AppMenuItem: FunctionComponent<{ item: MenuItem }> = ({ item }) =>
}
};
useEffect(() => {
if (item.shortcut) {
const offs: Callback[] = [];
offs.push(KeyHandler.onKey(item.shortcut, selectItem, KeyHandler.SHORTCUT_OPT));
if (item.shortcut !== Keys.DOM_VK_C) {
offs.push(KeyHandler.onKey(item.shortcut, selectItem, KeyHandler.SHORTCUT_ACTION));
}
return () => offs.forEach((off) => off());
}
}, [item.shortcut]);
const itemClicked = () => {
selectItem();
};

View File

@ -5,7 +5,6 @@ import { SecureInput, SecureInputEvent } from 'views/components/secure-input';
import { useLayoutEffect, useRef } from 'preact/hooks';
import { useEvent } from 'util/ui/hooks';
import { classes } from 'util/ui/classes';
import { FocusDetector } from 'comp/browser/focus-detector';
import { Features } from 'util/features';
export const OpenPasswordView: FunctionComponent<{