🐛 Fix incorrect behavior of Alt + Drag for variants

This commit is contained in:
Pablo Alba 2025-10-20 19:51:42 +02:00 committed by Pablo Alba
parent ca21e7e8b4
commit fd596a1371
3 changed files with 15 additions and 2 deletions

View File

@ -61,6 +61,7 @@
- Fix internal Error when selecting a set by name in the token theme editor [Taiga #12310](https://tree.taiga.io/project/penpot/issue/12310) - Fix internal Error when selecting a set by name in the token theme editor [Taiga #12310](https://tree.taiga.io/project/penpot/issue/12310)
- Fix drag & drop functionality is swapping instead or reordering [Taiga #12254](https://tree.taiga.io/project/penpot/issue/12254) - Fix drag & drop functionality is swapping instead or reordering [Taiga #12254](https://tree.taiga.io/project/penpot/issue/12254)
- Fix variants not syncronizing tokens on switch [Taiga #12290](https://tree.taiga.io/project/penpot/issue/12290) - Fix variants not syncronizing tokens on switch [Taiga #12290](https://tree.taiga.io/project/penpot/issue/12290)
- Fix incorrect behavior of Alt + Drag for variants [Taiga #12309](https://tree.taiga.io/project/penpot/issue/12309)
## 2.10.1 ## 2.10.1

View File

@ -2801,7 +2801,7 @@
(defn generate-duplicate-changes (defn generate-duplicate-changes
"Prepare objects to duplicate: generate new id, give them unique names, "Prepare objects to duplicate: generate new id, give them unique names,
move to the desired position, and recalculate parents and frames as needed." move to the desired position, and recalculate parents and frames as needed."
[changes all-objects page ids delta libraries library-data file-id & {:keys [variant-props]}] [changes all-objects page ids delta libraries library-data file-id & {:keys [variant-props alt-duplication?]}]
(let [shapes (map (d/getf all-objects) ids) (let [shapes (map (d/getf all-objects) ids)
unames (volatile! (cfh/get-used-names (:objects page))) unames (volatile! (cfh/get-used-names (:objects page)))
update-unames! (fn [new-name] (vswap! unames conj new-name)) update-unames! (fn [new-name] (vswap! unames conj new-name))
@ -2811,10 +2811,22 @@
;; we calculate a new one because the components will have created new shapes. ;; we calculate a new one because the components will have created new shapes.
ids-map (into {} (map #(vector % (uuid/next))) all-ids) ids-map (into {} (map #(vector % (uuid/next))) all-ids)
;; If there is an alt-duplication of a variant, change its parent to root
;; so the copy is made as a child of root
;; This is because inside a variant-container can't be a copy
shapes (map (fn [shape]
(if (and alt-duplication? (ctk/is-variant? shape))
(assoc shape :parent-id uuid/zero :frame-id nil)
shape))
shapes)
changes (-> changes changes (-> changes
(pcb/with-page page) (pcb/with-page page)
(pcb/with-objects all-objects) (pcb/with-objects all-objects)
(pcb/with-library-data library-data)) (pcb/with-library-data library-data))
changes changes
(->> shapes (->> shapes
(reduce #(generate-duplicate-shape-change %1 (reduce #(generate-duplicate-shape-change %1

View File

@ -463,7 +463,7 @@
library-data (dsh/lookup-file-data state file-id) library-data (dsh/lookup-file-data state file-id)
changes (-> (pcb/empty-changes it) changes (-> (pcb/empty-changes it)
(cll/generate-duplicate-changes objects page ids delta libraries library-data file-id) (cll/generate-duplicate-changes objects page ids delta libraries library-data file-id {:alt-duplication? alt-duplication?})
(cll/generate-duplicate-changes-update-indices objects ids)) (cll/generate-duplicate-changes-update-indices objects ids))
tags (or (:tags changes) #{}) tags (or (:tags changes) #{})