From b8c5fbec326f296f0525816ef8818ca5f372c22c Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Tue, 22 Dec 2020 16:43:56 +0800 Subject: [PATCH] fix(editor): events conflicts --- src/main/frontend/components/datetime.cljs | 3 ++- src/main/frontend/components/editor.cljs | 17 +++-------------- src/main/frontend/ui/date_picker.cljs | 3 ++- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/frontend/components/datetime.cljs b/src/main/frontend/components/datetime.cljs index bc2f94b380..bb0fd79bc9 100644 --- a/src/main/frontend/components/datetime.cljs +++ b/src/main/frontend/components/datetime.cljs @@ -9,7 +9,8 @@ [cljs-time.core :as t] [frontend.ui :as ui] [frontend.commands :as commands] - [clojure.string :as string])) + [clojure.string :as string] + [frontend.mixins :as mixins])) (defonce default-timestamp-value {:date nil :time "" diff --git a/src/main/frontend/components/editor.cljs b/src/main/frontend/components/editor.cljs index 4416c19cbf..7973b50fa9 100644 --- a/src/main/frontend/components/editor.cljs +++ b/src/main/frontend/components/editor.cljs @@ -495,7 +495,7 @@ (let [input-id (state/get-edit-input-id) input (and input-id (gdom/getElement id)) pos (and input (:pos (util/get-caret-pos input)))] - (when-not (state/get-editor-show-input) + (when (not @commands/*current-command) (util/stop e) (let [direction (if (gobj/get e "shiftKey") ; shift+tab move to left :left @@ -596,19 +596,8 @@ (let [matched-commands (editor-handler/get-matched-commands input)] (if (seq matched-commands) (do - (cond - (= key-code 9) ;tab - (when @*show-commands - (util/stop e) - (editor-handler/insert-command! input-id - (last (first matched-commands)) - format - nil)) - - :else - (do - (reset! *show-commands true) - (reset! *matched-commands matched-commands)))) + (reset! *show-commands true) + (reset! *matched-commands matched-commands)) (reset! *show-commands false)))) (when (and @*show-block-commands (not= key-code 188)) ; not < (let [matched-block-commands (editor-handler/get-matched-block-commands input)] diff --git a/src/main/frontend/ui/date_picker.cljs b/src/main/frontend/ui/date_picker.cljs index ea90f359e0..876ca24653 100644 --- a/src/main/frontend/ui/date_picker.cljs +++ b/src/main/frontend/ui/date_picker.cljs @@ -221,7 +221,8 @@ (when-not (input-or-select?) (swap! *internal-model inc-week 1)))} {:all-handler (fn [e key-code] - (when (contains? #{13} key-code) + (when (and (contains? #{13 37 39 38 40} key-code) + (not deadline-or-schedule?)) (util/stop e)))})))) {:init (fn [state] (reset! *internal-model (first (:rum/args state)))