From 2e13bea1c442a42914e1def37aae41d94bcacd5f Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Wed, 30 Sep 2026 08:56:19 +0200 Subject: [PATCH] :bug: Fix validation error when turning a component into a variant transform-in-variant (Ctrl+K on a component) runs a chain of events, each one committing its own changes. It set the variant-id on the main instance before setting it on the component, so the shape validation of that step saw them out of sync and rejected the change. The next steps then failed too, as the main instance was never a variant. Set the variant-id on the component first, and give the main instance an empty variant-name, which is what the validator expects while the variant has no properties yet. AI-assisted-by: claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 --- frontend/src/app/main/data/workspace/variants.cljs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/main/data/workspace/variants.cljs b/frontend/src/app/main/data/workspace/variants.cljs index d0a7a203e3..acfd59a3b3 100644 --- a/frontend/src/app/main/data/workspace/variants.cljs +++ b/frontend/src/app/main/data/workspace/variants.cljs @@ -440,8 +440,10 @@ cont-props (if flex? (into base-props flex-props) base-props) + ;; The variant has no properties yet, so its variant-name is empty main-props {:name name - :variant-id variant-id} + :variant-id variant-id + :variant-name ""} stroke-props {:stroke-alignment :inner :stroke-style :solid @@ -474,9 +476,11 @@ (cl/remove-all-fills variant-vec {:color clr/black :opacity 1}) (when flex? (dwsl/create-layout-from-id variant-id :flex)) (dwsh/update-shapes variant-vec #(merge % cont-props)) + ;; Set the variant-id on the component before the main shape, so the + ;; shape validation after updating the main sees both in sync + (set-variant-id component-id variant-id) (dwsh/update-shapes [main-instance-id] #(merge % main-props)) - (cl/add-stroke variant-vec stroke-props) - (set-variant-id component-id variant-id)) + (cl/add-stroke variant-vec stroke-props)) ;; Add the necessary number of new properties, with default values (rx/from