fix(editor): allow up/down arrows for repeater time selection

This commit is contained in:
Tienson Qin
2020-12-17 19:37:06 +08:00
parent c3538b2268
commit 42967ea782
5 changed files with 26 additions and 12 deletions

View File

@@ -179,10 +179,10 @@
(constantly true))]
(merge attributes {:selectable-fn selectable-fn})))
(defn- in-time-input?
(defn- input-or-select?
[]
(when-let [elem js/document.activeElement]
(= "time" (gobj/get elem "id"))))
(or (util/input? elem) (util/select? elem))))
(rum/defc date-picker < rum/reactive
(mixins/event-mixin
@@ -192,28 +192,31 @@
state
{;; enter, current day
13 (fn [state e]
(when on-change
(when (and on-change
(not (input-or-select?)))
(when-not deadline-or-schedule?
(on-change e @*internal-model))))
;; left, previous day
37 (fn [state e]
(when-not (in-time-input?)
(when-not (input-or-select?)
(swap! *internal-model inc-date -1)))
;; right, next day
39 (fn [state e]
(when-not (in-time-input?)
(when-not (input-or-select?)
(swap! *internal-model inc-date 1)))
;; up, one week ago
38 (fn [state e]
(swap! *internal-model inc-week -1))
(when-not (input-or-select?)
(swap! *internal-model inc-week -1)))
;; down, next week
40 (fn [state e]
(swap! *internal-model inc-week 1))}
(when-not (input-or-select?)
(swap! *internal-model inc-week 1)))}
{:all-handler (fn [e key-code]
(when (contains? #{13 38 40} key-code)
(when (contains? #{13} key-code)
(util/stop e)))}))))
{:init (fn [state]
(reset! *internal-model (first (:rum/args state)))