From d84ee8bb65da9d0521eedc6a062f804934cb4178 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 29 Jul 2025 12:48:56 +0200 Subject: [PATCH] :zap: Optimize mousetrap binding setup --- frontend/src/app/main/data/shortcuts.cljs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/main/data/shortcuts.cljs b/frontend/src/app/main/data/shortcuts.cljs index febed4486e..03d95d4eb3 100644 --- a/frontend/src/app/main/data/shortcuts.cljs +++ b/frontend/src/app/main/data/shortcuts.cljs @@ -142,23 +142,24 @@ [key cb] (fn [event] (log/debug :msg (str "Shortcut" key)) - (when (aget event "preventDefault") + (when (unchecked-get event "preventDefault") (.preventDefault event)) (cb event))) (defn- bind! [shortcuts] (let [msbind (fn [command callback type] - (if type - (mousetrap/bind command callback type) - (mousetrap/bind command callback)))] + (let [command (if (vector? command) + (into-array command) + command)] + (if type + (mousetrap/bind command callback type) + (mousetrap/bind command callback))))] (->> shortcuts (remove #(:disabled (second %))) (run! (fn [[key {:keys [command fn type]}]] (let [callback (wrap-cb key fn)] - (if (vector? command) - (run! #(msbind % callback type) command) - (msbind command callback type)))))))) + (msbind command callback type))))))) (defn- reset! ([]