0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 10:38:13 -05:00

🐛 Fix team modal auto focus handling.

This commit is contained in:
Andrey Antukh 2021-06-17 08:58:17 +02:00 committed by Andrés Moya
parent eacc945254
commit 231a133f23

View file

@ -62,20 +62,19 @@
(st/emit! (dd/update-team (with-meta team mdata)) (st/emit! (dd/update-team (with-meta team mdata))
(modal/hide)))) (modal/hide))))
(mf/defc team-form-modal (defn- on-submit
{::mf/register modal/components [form _]
(let [data (:clean-data @form)]
(if (:id data)
(on-update-submit form)
(on-create-submit form))))
(mf/defc team-form-modal {::mf/register modal/components
::mf/register-as :team-form} ::mf/register-as :team-form}
[{:keys [team] :as props}] [{:keys [team] :as props}]
(let [form (fm/use-form :spec ::team-form (let [initial (mf/use-memo (fn [] (or team {})))
:initial (or team {})) form (fm/use-form :spec ::team-form
:initial initial)]
on-submit
(mf/use-callback
(mf/deps team)
(if team
(partial on-update-submit form)
(partial on-create-submit form)))]
[:div.modal-overlay [:div.modal-overlay
[:div.modal-container.team-form-modal [:div.modal-container.team-form-modal
[:& fm/form {:form form :on-submit on-submit} [:& fm/form {:form form :on-submit on-submit}
@ -91,7 +90,7 @@
[:div.modal-content.generic-form [:div.modal-content.generic-form
[:& fm/input {:type "text" [:& fm/input {:type "text"
:auto-focus true :auto-focus? true
:form form :form form
:name :name :name :name
:label (tr "labels.create-team.placeholder")}]] :label (tr "labels.create-team.placeholder")}]]