mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 18:46:37 +02:00
Merge pull request #5812 from penpot/juanfran-create-edit-token-modal-enter-key
✨ Add missing enter key for button activation in edit/create tokens modal
This commit is contained in:
commit
dd1aba0d05
1 changed files with 23 additions and 1 deletions
|
@ -33,6 +33,7 @@
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.functions :as uf]
|
[app.util.functions :as uf]
|
||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
|
[app.util.keyboard :as k]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[malli.core :as m]
|
[malli.core :as m]
|
||||||
[malli.error :as me]
|
[malli.error :as me]
|
||||||
|
@ -416,7 +417,25 @@
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(mf/set-ref-val! cancel-ref nil)
|
(mf/set-ref-val! cancel-ref nil)
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(modal/hide!)))]
|
(modal/hide!)))
|
||||||
|
handle-key-down-delete
|
||||||
|
(mf/use-fn
|
||||||
|
(mf/deps on-delete-token)
|
||||||
|
(fn [e]
|
||||||
|
(when (k/enter? e)
|
||||||
|
(on-delete-token e))))
|
||||||
|
handle-key-down-cancel
|
||||||
|
(mf/use-fn
|
||||||
|
(mf/deps on-cancel)
|
||||||
|
(fn [e]
|
||||||
|
(when (k/enter? e)
|
||||||
|
(on-cancel e))))
|
||||||
|
handle-key-down-save
|
||||||
|
(mf/use-fn
|
||||||
|
(fn [e]
|
||||||
|
(mf/deps on-submit)
|
||||||
|
(when (k/enter? e)
|
||||||
|
(on-submit e))))]
|
||||||
|
|
||||||
;; Clear form token cache on mount
|
;; Clear form token cache on mount
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
|
@ -505,18 +524,21 @@
|
||||||
:with-delete (= action "edit"))}
|
:with-delete (= action "edit"))}
|
||||||
(when (= action "edit")
|
(when (= action "edit")
|
||||||
[:> button* {:on-click on-delete-token
|
[:> button* {:on-click on-delete-token
|
||||||
|
:on-key-down handle-key-down-delete
|
||||||
:class (stl/css :delete-btn)
|
:class (stl/css :delete-btn)
|
||||||
:type "button"
|
:type "button"
|
||||||
:icon i/delete
|
:icon i/delete
|
||||||
:variant "secondary"}
|
:variant "secondary"}
|
||||||
(tr "labels.delete")])
|
(tr "labels.delete")])
|
||||||
[:> button* {:on-click on-cancel
|
[:> button* {:on-click on-cancel
|
||||||
|
:on-key-down handle-key-down-cancel
|
||||||
:type "button"
|
:type "button"
|
||||||
:on-ref on-cancel-ref
|
:on-ref on-cancel-ref
|
||||||
:id "token-modal-cancel"
|
:id "token-modal-cancel"
|
||||||
:variant "secondary"}
|
:variant "secondary"}
|
||||||
(tr "labels.cancel")]
|
(tr "labels.cancel")]
|
||||||
[:> button* {:type "submit"
|
[:> button* {:type "submit"
|
||||||
|
:on-key-down handle-key-down-save
|
||||||
:variant "primary"
|
:variant "primary"
|
||||||
:disabled disabled?}
|
:disabled disabled?}
|
||||||
(tr "labels.save")]]]]))
|
(tr "labels.save")]]]]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue