mirror of
https://github.com/penpot/penpot.git
synced 2025-03-17 18:21:23 -05:00
✨ Allow enter to confirm dialog.
This commit is contained in:
parent
dc6b476c57
commit
d01921cd61
1 changed files with 17 additions and 2 deletions
|
@ -8,14 +8,17 @@
|
|||
;; Copyright (c) 2020 UXBOX Labs SL
|
||||
|
||||
(ns app.main.ui.confirm
|
||||
(:import goog.events.EventType)
|
||||
(:require
|
||||
[rumext.alpha :as mf]
|
||||
[goog.events :as events]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.main.ui.keyboard :as k]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr t]]
|
||||
[app.util.data :refer [classnames]]
|
||||
[rumext.alpha :as mf]))
|
||||
[app.util.data :refer [classnames]]))
|
||||
|
||||
(mf/defc confirm-dialog
|
||||
{::mf/register modal/components
|
||||
|
@ -52,6 +55,18 @@
|
|||
(st/emit! (modal/hide))
|
||||
(on-cancel props)))]
|
||||
|
||||
(mf/use-effect
|
||||
(fn []
|
||||
(let [on-keydown
|
||||
(fn [event]
|
||||
(when (k/enter? event)
|
||||
(do (dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (modal/hide))
|
||||
(on-accept props))))
|
||||
key (events/listen (dom/get-root) EventType.KEYDOWN on-keydown)]
|
||||
#(events/unlistenByKey key))))
|
||||
|
||||
[:div.modal-overlay
|
||||
[:div.modal-container.confirm-dialog
|
||||
[:div.modal-header
|
||||
|
|
Loading…
Add table
Reference in a new issue