mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 11:26:26 +00:00
improve(ui): support ESC close global modal dialog
This commit is contained in:
@@ -52,15 +52,16 @@
|
||||
;; (dissoc state name))})
|
||||
|
||||
(defn hide-when-esc-or-outside
|
||||
[state & {:keys [on-hide node visibilitychange?]}]
|
||||
[state & {:keys [on-hide node visibilitychange? outside?]}]
|
||||
(try
|
||||
(let [dom-node (rum/dom-node state)]
|
||||
(when-let [dom-node (or node dom-node)]
|
||||
(listen state js/window "mousedown"
|
||||
(fn [e]
|
||||
;; If the click target is outside of current node
|
||||
(when-not (dom/contains dom-node (.. e -target))
|
||||
(on-hide state e :click))))
|
||||
(or (false? outside?)
|
||||
(listen state js/window "mousedown"
|
||||
(fn [e]
|
||||
;; If the click target is outside of current node
|
||||
(when-not (dom/contains dom-node (.. e -target))
|
||||
(on-hide state e :click)))))
|
||||
(listen state js/window "keydown"
|
||||
(fn [e]
|
||||
(case (.-keyCode e)
|
||||
|
||||
Reference in New Issue
Block a user