Close action menu when pressing escape

pull/6283/head^2
Phoenix Eliot 2022-08-04 10:59:50 -04:00 committed by Tienson Qin
parent d39ae199fb
commit bc00dba369
2 changed files with 8 additions and 2 deletions

View File

@ -2874,7 +2874,7 @@
(when (and (not editor-action) (not non-enter-processed?)) (when (and (not editor-action) (not non-enter-processed?))
(cond (cond
;; When you type text inside square brackets ;; When you type text inside square brackets
(and (not (contains? #{"ArrowDown" "ArrowLeft" "ArrowRight" "ArrowUp"} k)) (and (not (contains? #{"ArrowDown" "ArrowLeft" "ArrowRight" "ArrowUp" "Escape"} k))
(wrapped-by? input page-ref/left-brackets page-ref/right-brackets)) (wrapped-by? input page-ref/left-brackets page-ref/right-brackets))
(let [orig-pos (cursor/get-caret-pos input) (let [orig-pos (cursor/get-caret-pos input)
value (gobj/get input "value") value (gobj/get input "value")

View File

@ -14,8 +14,14 @@
:on-hide :on-hide
(fn [_state e event] (fn [_state e event]
(let [target (.-target e)] (let [target (.-target e)]
(if (d/has-class? target "bottom-action") ;; FIXME: not particular case (cond
(state/get-editor-action)
(state/clear-editor-action!) ;; FIXME: This should probably be handled as a keydown handler in editor, but this handler intercepts Esc first
(d/has-class? target "bottom-action") ;; FIXME: not particular case
(.preventDefault e) (.preventDefault e)
:else
(let [{:keys [on-hide value]} (editor-handler/get-state)] (let [{:keys [on-hide value]} (editor-handler/get-state)]
(when on-hide (when on-hide
(on-hide value event)) (on-hide value event))