mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 19:06:18 +00:00
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:
parent
8e51aa8df4
commit
03b5d44a7c
@ -343,8 +343,8 @@
|
|||||||
"Given the id of a main shape of a component, creates a variant structure for
|
"Given the id of a main shape of a component, creates a variant structure for
|
||||||
that component"
|
that component"
|
||||||
([main-instance-id]
|
([main-instance-id]
|
||||||
(transform-in-variant main-instance-id nil nil [] true true))
|
(transform-in-variant main-instance-id nil nil [] false true true))
|
||||||
([main-instance-id variant-id delta prefix duplicate? flex?]
|
([main-instance-id variant-id delta prefix add-wrapper? duplicate? flex?]
|
||||||
(ptk/reify ::transform-in-variant
|
(ptk/reify ::transform-in-variant
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
@ -356,8 +356,11 @@
|
|||||||
main (get objects main-instance-id)
|
main (get objects main-instance-id)
|
||||||
parent (get objects (:parent-id main))
|
parent (get objects (:parent-id main))
|
||||||
component-id (:component-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
|
;; If there is a prefix, set is as first item of path
|
||||||
cpath (-> (:name main)
|
cpath (-> name
|
||||||
cfh/split-path
|
cfh/split-path
|
||||||
(cond->
|
(cond->
|
||||||
(seq prefix)
|
(seq prefix)
|
||||||
@ -580,6 +583,8 @@
|
|||||||
prefix (->> shapes
|
prefix (->> shapes
|
||||||
(mapv #(cfh/split-path (:name %)))
|
(mapv #(cfh/split-path (:name %)))
|
||||||
(common-prefix))
|
(common-prefix))
|
||||||
|
;; When the common parent is root, add a wrapper
|
||||||
|
add-wrapper? (= prefix [])
|
||||||
first-shape (first shapes)
|
first-shape (first shapes)
|
||||||
delta (gpt/point (- (:x rect) (:x first-shape) 30)
|
delta (gpt/point (- (:x rect) (:x first-shape) 30)
|
||||||
(- (:y rect) (:y first-shape) 30))
|
(- (:y rect) (:y first-shape) 30))
|
||||||
@ -598,7 +603,7 @@
|
|||||||
(when (and page-id (not= current-page page-id))
|
(when (and page-id (not= current-page page-id))
|
||||||
(dcm/go-to-workspace :page-id page-id))
|
(dcm/go-to-workspace :page-id page-id))
|
||||||
(dwu/start-undo-transaction undo-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)
|
(dwsh/relocate-shapes (into #{} (-> selected rest reverse)) variant-id 0)
|
||||||
(dwt/update-dimensions [variant-id] :width (+ (:width rect) 60))
|
(dwt/update-dimensions [variant-id] :width (+ (:width rect) 60))
|
||||||
(dwt/update-dimensions [variant-id] :height (+ (:height rect) 60))
|
(dwt/update-dimensions [variant-id] :height (+ (:height rect) 60))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user