From f444a029f8aa6f0ae946e4b011facc79efd74940 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Mon, 7 Oct 2024 10:43:50 +0200 Subject: [PATCH] add mousetrap type --- package.json | 1 + src/renderer/src/components/KeyboardShortcuts.tsx | 5 ++++- src/renderer/src/hooks/useKeyboard.ts | 4 +++- yarn.lock | 8 ++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f9df0f28..92bc276d 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "@types/luxon": "^3.4.2", "@types/mime-types": "^2.1.4", "@types/morgan": "^1.9.9", + "@types/mousetrap": "^1.6.15", "@types/node": "18", "@types/react": "^18.2.66", "@types/react-dom": "^18.2.22", diff --git a/src/renderer/src/components/KeyboardShortcuts.tsx b/src/renderer/src/components/KeyboardShortcuts.tsx index a3955d28..083f05ec 100644 --- a/src/renderer/src/components/KeyboardShortcuts.tsx +++ b/src/renderer/src/components/KeyboardShortcuts.tsx @@ -49,7 +49,10 @@ function fixKeys(keys: string[]) { const CreateBinding = memo(({ actionsMap, action, setCreatingBinding, onNewKeyBindingConfirmed, }: { - actionsMap: ActionsMap, action: KeyboardAction | undefined, setCreatingBinding: Dispatch>, onNewKeyBindingConfirmed: (a: KeyboardAction, keys: string[]) => void, + actionsMap: ActionsMap, + action: KeyboardAction | undefined, + setCreatingBinding: Dispatch>, + onNewKeyBindingConfirmed: (a: KeyboardAction, keys: string[]) => void, }) => { const { t } = useTranslation(); diff --git a/src/renderer/src/hooks/useKeyboard.ts b/src/renderer/src/hooks/useKeyboard.ts index 02741e01..1bdad856 100644 --- a/src/renderer/src/hooks/useKeyboard.ts +++ b/src/renderer/src/hooks/useKeyboard.ts @@ -40,6 +40,8 @@ export default ({ keyBindings, onKeyPress: onKeyPressProp }: { } }); - return () => mousetrap.reset(); + return () => { + mousetrap.reset(); + }; }, [keyBindings]); }; diff --git a/yarn.lock b/yarn.lock index 8e3d08df..4f302cd8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2149,6 +2149,13 @@ __metadata: languageName: node linkType: hard +"@types/mousetrap@npm:^1.6.15": + version: 1.6.15 + resolution: "@types/mousetrap@npm:1.6.15" + checksum: 10/58ec552218108f8e5f0d40ee81579aafbdb00c3af0ef4b6d3fb193a8a11a2d37aa84c6e20524120b7f218c2a87dac24f426ee3b23e1269d42f8145a1a37c9eca + languageName: node + linkType: hard + "@types/ms@npm:*": version: 0.7.31 resolution: "@types/ms@npm:0.7.31" @@ -7610,6 +7617,7 @@ __metadata: "@types/luxon": "npm:^3.4.2" "@types/mime-types": "npm:^2.1.4" "@types/morgan": "npm:^1.9.9" + "@types/mousetrap": "npm:^1.6.15" "@types/node": "npm:18" "@types/react": "npm:^18.2.66" "@types/react-dom": "npm:^18.2.22"