mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 05:50:35 +00:00
🐛 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 <noreply@anthropic.com>
This commit is contained in:
parent
387f0cb5dc
commit
2e13bea1c4
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user