Skip to content

A local-first personal finance app

:arrow_up: upgrade hotkeys-js from v3.8.2 to v3.10.3, remove monkeypatch (#1195)

Matiss Janis Aboltinsb7d5602ccefe
diff --git a/packages/desktop-client/package.json b/packages/desktop-client/package.json
index df730fce1b..e6bf34b0b3 100644
--- a/packages/desktop-client/package.json
+++ b/packages/desktop-client/package.json
@@ -31,7 +31,7 @@
"focus-visible": "^4.1.1",
"formik": "^0.11.10",
"glamor": "^2.20.40",
- "hotkeys-js": "3.8.2",
+ "hotkeys-js": "3.10.3",
"identity-obj-proxy": "3.0.0",
"inter-ui": "^3.19.3",
"jest": "^27.0.0",
diff --git a/packages/desktop-client/src/components/accounts/Account.js b/packages/desktop-client/src/components/accounts/Account.js
index 296af367f1..c94190e647 100644
--- a/packages/desktop-client/src/components/accounts/Account.js
+++ b/packages/desktop-client/src/components/accounts/Account.js
@@ -735,7 +735,7 @@ const AccountHeader = memo(
<>
<KeyHandlers
keys={{
- 'mod+f': () => {
+ 'ctrl+f, cmd+f': () => {
if (searchInput.current) {
searchInput.current.focus();
}
diff --git a/patches/hotkeys-js+3.8.2.patch b/patches/hotkeys-js+3.8.2.patch
deleted file mode 100644
index 59831a3c99..0000000000
--- a/patches/hotkeys-js+3.8.2.patch
+++ /dev/null
@@ -1,94 +0,0 @@
-diff --git a/node_modules/hotkeys-js/dist/hotkeys.common.js b/node_modules/hotkeys-js/dist/hotkeys.common.js
-index bc18534..34c0d7d 100644
---- a/node_modules/hotkeys-js/dist/hotkeys.common.js
-+++ b/node_modules/hotkeys-js/dist/hotkeys.common.js
-@@ -22,7 +22,6 @@ function addEvent(object, event, method) {
- }
- } // 修饰键转换成对应的键码
-
--
- function getMods(modifier, key) {
- var mods = key.slice(0, key.length - 1);
-
-@@ -33,7 +32,6 @@ function getMods(modifier, key) {
- return mods;
- } // 处理传的key字符串转换成数组
-
--
- function getKeys(key) {
- if (typeof key !== 'string') key = '';
- key = key.replace(/\s/g, ''); // 匹配任何空白字符,包括空格、制表符、换页符等等
-diff --git a/node_modules/hotkeys-js/dist/hotkeys.esm.js b/node_modules/hotkeys-js/dist/hotkeys.esm.js
-index 90295a5..f998483 100644
---- a/node_modules/hotkeys-js/dist/hotkeys.esm.js
-+++ b/node_modules/hotkeys-js/dist/hotkeys.esm.js
-@@ -9,6 +9,8 @@
- */
-
- var isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; // 绑定事件
-+var ismac =
-+ navigator.platform && navigator.platform.toUpperCase().indexOf('MAC') >= 0;
-
- function addEvent(object, event, method) {
- if (object.addEventListener) {
-@@ -20,12 +22,20 @@ function addEvent(object, event, method) {
- }
- } // 修饰键转换成对应的键码
-
--
- function getMods(modifier, key) {
- var mods = key.slice(0, key.length - 1);
-
- for (var i = 0; i < mods.length; i++) {
-- mods[i] = modifier[mods[i].toLowerCase()];
-+ let mod = mods[i].toLowerCase();
-+ if(mod === 'mod') {
-+ if(ismac) {
-+ mod = 'cmd';
-+ }
-+ else {
-+ mod = 'ctrl';
-+ }
-+ }
-+ mods[i] = modifier[mod];
- }
-
- return mods;
-@@ -145,6 +155,9 @@ var elementHasBindEvent = []; // 已绑定事件的节点记录
- // 返回键码
-
- var code = function code(x) {
-+ if(x === 'mod') {
-+ x = ismac ? 'cmd' : 'ctrl'
-+ }
- return _keyMap[x.toLowerCase()] || _modifier[x.toLowerCase()] || x.toUpperCase().charCodeAt(0);
- }; // 设置获取当前范围(默认为'所有')
-
-@@ -319,7 +332,6 @@ function eventHandler(event, handler, scope) {
- }
- } // 调用处理程序,如果是修饰键不做处理
-
--
- if (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91] || modifiersMatch || handler.shortcut === '*') {
- if (handler.method(event, handler) === false) {
- if (event.preventDefault) event.preventDefault();else event.returnValue = false;
-diff --git a/node_modules/hotkeys-js/dist/hotkeys.js b/node_modules/hotkeys-js/dist/hotkeys.js
-index 15480e8..d203a42 100644
---- a/node_modules/hotkeys-js/dist/hotkeys.js
-+++ b/node_modules/hotkeys-js/dist/hotkeys.js
-@@ -26,7 +26,6 @@
- }
- } // 修饰键转换成对应的键码
-
--
- function getMods(modifier, key) {
- var mods = key.slice(0, key.length - 1);
-
-@@ -37,7 +36,6 @@
- return mods;
- } // 处理传的key字符串转换成数组
-
--
- function getKeys(key) {
- if (typeof key !== 'string') key = '';
- key = key.replace(/\s/g, ''); // 匹配任何空白字符,包括空格、制表符、换页符等等
diff --git a/upcoming-release-notes/1195.md b/upcoming-release-notes/1195.md
new file mode 100644
index 0000000000..4aca868c05
--- /dev/null
+++ b/upcoming-release-notes/1195.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [MatissJanis]
+---
+
+Upgrade `hotkeys-js` and remove monkeypatch
diff --git a/yarn.lock b/yarn.lock
index ccf33b1e55..0cedf12f01 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -94,7 +94,7 @@ __metadata:
focus-visible: ^4.1.1
formik: ^0.11.10
glamor: ^2.20.40
- hotkeys-js: 3.8.2
+ hotkeys-js: 3.10.3
identity-obj-proxy: 3.0.0
inter-ui: ^3.19.3
jest: ^27.0.0
@@ -10002,10 +10002,10 @@ __metadata:
languageName: node
linkType: hard
-"hotkeys-js@npm:3.8.2":
- version: 3.8.2
- resolution: "hotkeys-js@npm:3.8.2"
- checksum: 0fbe8e4a1b3091b9bb1ed2ca220509bda5337a0ab6a90b963ee2a942e06aef25eb4294ca7048f30a00be41f14002691e153c17797a4c0604fde71011318bb05f
+"hotkeys-js@npm:3.10.3":
+ version: 3.10.3
+ resolution: "hotkeys-js@npm:3.10.3"
+ checksum: c88bbb1178e61a0e52129a22ef4083c2f40de6d57041df1b18baa376424726073d122423ee125dfb92fdc5811ef1c0cd5e0bb394fc9f5a012a84653fd17dc76f
languageName: node
linkType: hard