Merge pull request #7101 from penpot/palba-variants-bulk-root

🐛 Fix bad name on variants bulk when the parent is root
This commit is contained in:
Pablo Alba 2025-08-12 17:04:13 +02:00 committed by GitHub
parent 8e51aa8df4
commit 03b5d44a7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -343,8 +343,8 @@
"Given the id of a main shape of a component, creates a variant structure for
that component"
([main-instance-id]
(transform-in-variant main-instance-id nil nil [] true true))
([main-instance-id variant-id delta prefix duplicate? flex?]
(transform-in-variant main-instance-id nil nil [] false true true))
([main-instance-id variant-id delta prefix add-wrapper? duplicate? flex?]
(ptk/reify ::transform-in-variant
ptk/WatchEvent
(watch [_ state _]
@ -356,8 +356,11 @@
main (get objects main-instance-id)
parent (get objects (:parent-id main))
component-id (:component-id main)
name (if add-wrapper?
(str "Component/" (:name main))
(:name main))
;; If there is a prefix, set is as first item of path
cpath (-> (:name main)
cpath (-> name
cfh/split-path
(cond->
(seq prefix)
@ -580,6 +583,8 @@
prefix (->> shapes
(mapv #(cfh/split-path (:name %)))
(common-prefix))
;; When the common parent is root, add a wrapper
add-wrapper? (= prefix [])
first-shape (first shapes)
delta (gpt/point (- (:x rect) (:x first-shape) 30)
(- (:y rect) (:y first-shape) 30))
@ -598,7 +603,7 @@
(when (and page-id (not= current-page page-id))
(dcm/go-to-workspace :page-id page-id))
(dwu/start-undo-transaction undo-id)
(transform-in-variant (first selected) variant-id delta prefix false false)
(transform-in-variant (first selected) variant-id delta prefix add-wrapper? false false)
(dwsh/relocate-shapes (into #{} (-> selected rest reverse)) variant-id 0)
(dwt/update-dimensions [variant-id] :width (+ (:width rect) 60))
(dwt/update-dimensions [variant-id] :height (+ (:height rect) 60))