mirror of
https://github.com/penpot/penpot.git
synced 2025-04-16 00:41:25 -05: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.functions :as uf]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[app.util.keyboard :as k]
|
||||
[cuerdas.core :as str]
|
||||
[malli.core :as m]
|
||||
[malli.error :as me]
|
||||
|
@ -416,7 +417,25 @@
|
|||
(fn [e]
|
||||
(mf/set-ref-val! cancel-ref nil)
|
||||
(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
|
||||
(mf/use-effect
|
||||
|
@ -505,18 +524,21 @@
|
|||
:with-delete (= action "edit"))}
|
||||
(when (= action "edit")
|
||||
[:> button* {:on-click on-delete-token
|
||||
:on-key-down handle-key-down-delete
|
||||
:class (stl/css :delete-btn)
|
||||
:type "button"
|
||||
:icon i/delete
|
||||
:variant "secondary"}
|
||||
(tr "labels.delete")])
|
||||
[:> button* {:on-click on-cancel
|
||||
:on-key-down handle-key-down-cancel
|
||||
:type "button"
|
||||
:on-ref on-cancel-ref
|
||||
:id "token-modal-cancel"
|
||||
:variant "secondary"}
|
||||
(tr "labels.cancel")]
|
||||
[:> button* {:type "submit"
|
||||
:on-key-down handle-key-down-save
|
||||
:variant "primary"
|
||||
:disabled disabled?}
|
||||
(tr "labels.save")]]]]))
|
||||
|
|
Loading…
Add table
Reference in a new issue