diff --git a/frontend/src/app/main/data/workspace/variants.cljs b/frontend/src/app/main/data/workspace/variants.cljs index c9834b847a..6c72decde7 100644 --- a/frontend/src/app/main/data/workspace/variants.cljs +++ b/frontend/src/app/main/data/workspace/variants.cljs @@ -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))