mirror of
https://github.com/penpot/penpot.git
synced 2026-04-29 05:08:08 +00:00
✨ Treat empty names as a malformed formula (#7073)
This commit is contained in:
parent
db9349e764
commit
0a02e526ee
@ -71,7 +71,7 @@
|
||||
component (ctcl/get-component data component-id true)
|
||||
main-id (:main-instance-id component)]
|
||||
(-> changes
|
||||
(pcb/update-shapes [main-id] (if (str/blank? value)
|
||||
(pcb/update-shapes [main-id] (if (nil? value)
|
||||
#(dissoc % :variant-error)
|
||||
#(assoc % :variant-error value))))))
|
||||
|
||||
|
||||
@ -135,25 +135,27 @@
|
||||
|
||||
|
||||
(defn update-error
|
||||
"Updates the error in a component"
|
||||
[component-id value]
|
||||
(ptk/reify ::update-error
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
data (dsh/lookup-file-data state)
|
||||
objects (-> (dsh/get-page data page-id)
|
||||
(get :objects))
|
||||
"Sets or unsets an error for a component"
|
||||
([component-id]
|
||||
(update-error component-id nil))
|
||||
([component-id value]
|
||||
(ptk/reify ::update-error
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
data (dsh/lookup-file-data state)
|
||||
objects (-> (dsh/get-page data page-id)
|
||||
(get :objects))
|
||||
|
||||
changes (-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-library-data data)
|
||||
(pcb/with-objects objects)
|
||||
(clvp/generate-set-variant-error component-id value))
|
||||
undo-id (js/Symbol)]
|
||||
(rx/of
|
||||
(dwu/start-undo-transaction undo-id)
|
||||
(dch/commit-changes changes)
|
||||
(dwu/commit-undo-transaction undo-id))))))
|
||||
changes (-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-library-data data)
|
||||
(pcb/with-objects objects)
|
||||
(clvp/generate-set-variant-error component-id value))
|
||||
undo-id (js/Symbol)]
|
||||
(rx/of
|
||||
(dwu/start-undo-transaction undo-id)
|
||||
(dch/commit-changes changes)
|
||||
(dwu/commit-undo-transaction undo-id)))))))
|
||||
|
||||
|
||||
(defn remove-property
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
(if (ctv/valid-properties-formula? name)
|
||||
(st/emit! (dwv/update-properties-names-and-values component-id variant-id variant-properties (ctv/properties-formula->map name))
|
||||
(dwv/remove-empty-properties variant-id)
|
||||
(dwv/update-error component-id nil))
|
||||
(dwv/update-error component-id))
|
||||
(st/emit! (dwv/update-properties-names-and-values component-id variant-id variant-properties {})
|
||||
(dwv/remove-empty-properties variant-id)
|
||||
(dwv/update-error component-id name)))
|
||||
|
||||
@ -339,7 +339,7 @@
|
||||
(let [value (d/nilv (str/trim value) "")]
|
||||
(doseq [id component-ids]
|
||||
(st/emit! (dwv/update-property-value id pos value))
|
||||
(st/emit! (dwv/update-error id nil))))))
|
||||
(st/emit! (dwv/update-error id))))))
|
||||
|
||||
update-property-name
|
||||
(mf/use-fn
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user