mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
Dont show name error when editing new token and not touching name field
This commit is contained in:
parent
49ff0df7f6
commit
308fff05c3
1 changed files with 6 additions and 2 deletions
|
@ -169,7 +169,8 @@ Token names should only contain letters and digits separated by . characters.")}
|
||||||
(mf/defc form
|
(mf/defc form
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[{:keys [token token-type]}]
|
[{:keys [token token-type]}]
|
||||||
(let [token (or token {:type token-type})
|
(let [validate-name? (mf/use-state (not (:id token)))
|
||||||
|
token (or token {:type token-type})
|
||||||
color? (wtt/color-token? token)
|
color? (wtt/color-token? token)
|
||||||
selected-set-tokens (mf/deref refs/workspace-selected-token-set-tokens)
|
selected-set-tokens (mf/deref refs/workspace-selected-token-set-tokens)
|
||||||
active-theme-tokens (mf/deref refs/workspace-active-theme-sets-tokens)
|
active-theme-tokens (mf/deref refs/workspace-active-theme-sets-tokens)
|
||||||
|
@ -198,7 +199,10 @@ Token names should only contain letters and digits separated by . characters.")}
|
||||||
(debounce (fn [e]
|
(debounce (fn [e]
|
||||||
(let [value (dom/get-target-val e)
|
(let [value (dom/get-target-val e)
|
||||||
errors (validate-name value)]
|
errors (validate-name value)]
|
||||||
(reset! name-errors errors)))))
|
;; Prevent showing error when just going to another field on a new token
|
||||||
|
(when-not (and validate-name? (str/empty? value))
|
||||||
|
(reset! validate-name? false)
|
||||||
|
(reset! name-errors errors))))))
|
||||||
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]
|
||||||
|
|
Loading…
Reference in a new issue