diff --git a/common/src/app/common/logic/variant_properties.cljc b/common/src/app/common/logic/variant_properties.cljc index 326f2edf92..f2f056f660 100644 --- a/common/src/app/common/logic/variant_properties.cljc +++ b/common/src/app/common/logic/variant_properties.cljc @@ -42,7 +42,7 @@ changes related-components) - ids-to-validate (conj (mapv :main-instance-id related-components) variant-id) + ids-to-validate [variant-id] changes (pcb/validate-shapes changes (pcb/get-page-id changes) @@ -74,7 +74,7 @@ changes related-components) - ids-to-validate (conj (mapv :main-instance-id related-components) variant-id) + ids-to-validate [variant-id] changes (pcb/validate-shapes changes (pcb/get-page-id changes) @@ -97,7 +97,9 @@ (update pos assoc :value value) ctv/properties-to-name) - ids-to-validate [main-id (:variant-id component)]] + ids-to-validate (if-let [variant-id (:variant-id component)] + [variant-id] + [main-id])] (-> changes (pcb/update-component component-id #(assoc-in % [:variant-properties pos :value] value) {:apply-changes-local-library? true}) @@ -118,7 +120,9 @@ component (ctcl/get-component data component-id true)] (if component (let [main-id (:main-instance-id component) - ids-to-validate [main-id (:variant-id component)]] + ids-to-validate (if-let [variant-id (:variant-id component)] + [variant-id] + [main-id])] (-> changes (pcb/update-shapes [main-id] (if (nil? value) #(dissoc % :variant-error) @@ -157,7 +161,7 @@ related-components)] (if (identical? changes changes') changes - (let [ids-to-validate (conj (mapv :main-instance-id related-components) variant-id)] + (let [ids-to-validate [variant-id]] (pcb/validate-shapes changes' (pcb/get-page-id changes') ids-to-validate @@ -220,7 +224,7 @@ (if (or skip-validation? (empty? related-components)) changes - (let [ids-to-validate (conj (mapv :main-instance-id related-components) variant-id)] + (let [ids-to-validate [variant-id]] (pcb/validate-shapes changes (pcb/get-page-id changes) ids-to-validate @@ -360,7 +364,7 @@ (if (or skip-validation? (zero? num-shapes) (empty? shapes)) changes - (let [ids-to-validate (conj (mapv :id shapes) variant-id)] + (let [ids-to-validate [variant-id]] (pcb/validate-shapes changes (pcb/get-page-id changes) ids-to-validate diff --git a/common/test/common_tests/logic/variant_properties_test.cljc b/common/test/common_tests/logic/variant_properties_test.cljc index 8f2235bc22..fed63093ec 100644 --- a/common/test/common_tests/logic/variant_properties_test.cljc +++ b/common/test/common_tests/logic/variant_properties_test.cljc @@ -6,6 +6,7 @@ (ns common-tests.logic.variant-properties-test (:require + [app.common.files.changes :as cfc] [app.common.files.changes-builder :as pcb] [app.common.logic.shapes :as cls] [app.common.logic.variant-properties :as clvp] @@ -359,6 +360,20 @@ (t/is (nil? (:variant-error main01'))))) +(t/deftest test-set-variant-error-non-variant-component + (let [file (-> (thf/sample-file :file1) + (tho/add-simple-component :c01 :m01 :sh01)) + page (thf/current-page file) + c01-id (:id (thc/get-component file :c01)) + + changes (-> (pcb/empty-changes nil) + (pcb/with-page-id (:id page)) + (pcb/with-library-data (:data file)) + (pcb/with-objects (:objects page)) + (clvp/generate-set-variant-error c01-id "bad=value"))] + + (t/is (cfc/check-changes (:redo-changes changes))))) + ;; ============================================================================= ;; generate-reorder-variant-poperties tests ;; =============================================================================