mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 22:49:01 -05:00
Remove form-touched work-around
This commit is contained in:
parent
eac7d9288b
commit
5df0cf545e
1 changed files with 2 additions and 10 deletions
|
@ -118,10 +118,6 @@
|
||||||
;; Allow setting token to already used name
|
;; Allow setting token to already used name
|
||||||
(disj (:name token)))))
|
(disj (:name token)))))
|
||||||
|
|
||||||
form-touched (mf/use-state nil)
|
|
||||||
update-form-touched (mf/use-callback
|
|
||||||
(debounce #(reset! form-touched (js/Symbol)) 120))
|
|
||||||
|
|
||||||
;; Name
|
;; Name
|
||||||
name-ref (mf/use-var (:name token))
|
name-ref (mf/use-var (:name token))
|
||||||
name-errors (mf/use-state nil)
|
name-errors (mf/use-state nil)
|
||||||
|
@ -133,8 +129,7 @@
|
||||||
(let [value (dom/get-target-val e)
|
(let [value (dom/get-target-val e)
|
||||||
errors (->> (finalize-name value)
|
errors (->> (finalize-name value)
|
||||||
(m/explain name-schema))]
|
(m/explain name-schema))]
|
||||||
(reset! name-errors errors)
|
(reset! name-errors errors)))))
|
||||||
(update-form-touched)))))
|
|
||||||
on-update-name (mf/use-callback
|
on-update-name (mf/use-callback
|
||||||
(mf/deps on-update-name-debounced)
|
(mf/deps on-update-name-debounced)
|
||||||
(fn [e]
|
(fn [e]
|
||||||
|
@ -173,8 +168,7 @@
|
||||||
(debounce (fn [e]
|
(debounce (fn [e]
|
||||||
(let [value (dom/get-target-val e)
|
(let [value (dom/get-target-val e)
|
||||||
errors (m/explain token-description-schema value)]
|
errors (m/explain token-description-schema value)]
|
||||||
(reset! description-errors errors)
|
(reset! description-errors errors)))))
|
||||||
(update-form-touched)))))
|
|
||||||
on-update-description (mf/use-callback
|
on-update-description (mf/use-callback
|
||||||
(mf/deps on-update-description-debounced)
|
(mf/deps on-update-description-debounced)
|
||||||
(fn [e]
|
(fn [e]
|
||||||
|
@ -189,14 +183,12 @@
|
||||||
|
|
||||||
on-submit (mf/use-callback
|
on-submit (mf/use-callback
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(js/console.log "@value-ref" @value-ref (finalize-value @value-ref))
|
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(let [token (cond-> {:name (finalize-name @name-ref)
|
(let [token (cond-> {:name (finalize-name @name-ref)
|
||||||
:type (or (:type token) token-type)
|
:type (or (:type token) token-type)
|
||||||
:value (finalize-value @value-ref)}
|
:value (finalize-value @value-ref)}
|
||||||
@description-ref (assoc :description @description-ref)
|
@description-ref (assoc :description @description-ref)
|
||||||
(:id token) (assoc :id (:id token)))]
|
(:id token) (assoc :id (:id token)))]
|
||||||
(js/console.log "token" token)
|
|
||||||
(st/emit! (dt/add-token token))
|
(st/emit! (dt/add-token token))
|
||||||
(modal/hide!))))]
|
(modal/hide!))))]
|
||||||
[:form
|
[:form
|
||||||
|
|
Loading…
Add table
Reference in a new issue