mirror of
https://github.com/penpot/penpot.git
synced 2025-06-09 02:41:38 +02:00
🐛 Fix when changing order on main+flex, the copies are badly updated
This commit is contained in:
parent
76ec610d44
commit
3e965c96e7
3 changed files with 13 additions and 11 deletions
|
@ -467,7 +467,7 @@
|
||||||
(d/update-in-when data [:components component-id :objects] reg-objects))))
|
(d/update-in-when data [:components component-id :objects] reg-objects))))
|
||||||
|
|
||||||
(defmethod process-change :mov-objects
|
(defmethod process-change :mov-objects
|
||||||
[data {:keys [parent-id shapes index page-id component-id ignore-touched after-shape component-swap]}]
|
[data {:keys [parent-id shapes index page-id component-id ignore-touched after-shape component-swap syncing]}]
|
||||||
(letfn [(calculate-invalid-targets [objects shape-id]
|
(letfn [(calculate-invalid-targets [objects shape-id]
|
||||||
(let [reduce-fn #(into %1 (calculate-invalid-targets objects %2))]
|
(let [reduce-fn #(into %1 (calculate-invalid-targets objects %2))]
|
||||||
(->> (get-in objects [shape-id :shapes])
|
(->> (get-in objects [shape-id :shapes])
|
||||||
|
@ -475,15 +475,15 @@
|
||||||
|
|
||||||
;; Avoid placing a shape as a direct or indirect child of itself,
|
;; Avoid placing a shape as a direct or indirect child of itself,
|
||||||
;; or inside its main component if it's in a copy,
|
;; or inside its main component if it's in a copy,
|
||||||
;; or inside a copy
|
;; or inside a copy, or from a copy
|
||||||
(is-valid-move? [objects shape-id]
|
(is-valid-move? [objects shape-id]
|
||||||
(let [invalid-targets (calculate-invalid-targets objects shape-id)
|
(let [invalid-targets (calculate-invalid-targets objects shape-id)
|
||||||
shape (get objects shape-id)
|
shape (get objects shape-id)]
|
||||||
_ (prn "is-valid-move?")]
|
|
||||||
(and shape
|
(and shape
|
||||||
(not (invalid-targets parent-id))
|
(not (invalid-targets parent-id))
|
||||||
(not (cfh/components-nesting-loop? objects shape-id parent-id))
|
(not (cfh/components-nesting-loop? objects shape-id parent-id))
|
||||||
(or component-swap
|
(or component-swap ;; On a component swap it's allowed to change the structure of a copy
|
||||||
|
syncing ;; If we are syncing the changes of a main component, it's allowed to change the structure of a copy
|
||||||
(and
|
(and
|
||||||
(not (ctk/in-component-copy? (get objects (:parent-id shape)))) ;; We don't want to change the structure of component copies
|
(not (ctk/in-component-copy? (get objects (:parent-id shape)))) ;; We don't want to change the structure of component copies
|
||||||
(not (ctk/in-component-copy? (get objects parent-id)))))))) ;; We need to check the origin and target frames
|
(not (ctk/in-component-copy? (get objects parent-id)))))))) ;; We need to check the origin and target frames
|
||||||
|
|
|
@ -946,16 +946,16 @@
|
||||||
|
|
||||||
changes (pcb/concat-changes library-changes file-changes)
|
changes (pcb/concat-changes library-changes file-changes)
|
||||||
|
|
||||||
find-shape (fn [data]
|
extract-shapes (fn [change]
|
||||||
(for [page-id [(:page-id data)]
|
(for [page-id [(:page-id change)]
|
||||||
id (:shapes data)]
|
id (:shapes change)]
|
||||||
(-> (get-in state [:workspace-data :pages-index page-id :objects id])
|
(-> (get-in state [:workspace-data :pages-index page-id :objects id])
|
||||||
(assoc :page-id page-id))))
|
(assoc :page-id page-id))))
|
||||||
|
|
||||||
updated-copies (->> changes
|
updated-copies (->> changes
|
||||||
:redo-changes
|
:redo-changes
|
||||||
(filter #(= (:type %) :reg-objects))
|
(filter #(= (:type %) :reg-objects))
|
||||||
(mapcat find-shape)
|
(mapcat extract-shapes)
|
||||||
(filter ctk/instance-head?)
|
(filter ctk/instance-head?)
|
||||||
distinct)]
|
distinct)]
|
||||||
|
|
||||||
|
|
|
@ -1141,14 +1141,16 @@
|
||||||
:parent-id (:parent-id shape)
|
:parent-id (:parent-id shape)
|
||||||
:shapes [(:id shape)]
|
:shapes [(:id shape)]
|
||||||
:index index-after
|
:index index-after
|
||||||
:ignore-touched true}))
|
:ignore-touched true
|
||||||
|
:syncing true}))
|
||||||
(update :undo-changes conj (make-change
|
(update :undo-changes conj (make-change
|
||||||
container
|
container
|
||||||
{:type :mov-objects
|
{:type :mov-objects
|
||||||
:parent-id (:parent-id shape)
|
:parent-id (:parent-id shape)
|
||||||
:shapes [(:id shape)]
|
:shapes [(:id shape)]
|
||||||
:index index-before
|
:index index-before
|
||||||
:ignore-touched true})))]
|
:ignore-touched true
|
||||||
|
:syncing true})))]
|
||||||
|
|
||||||
(if (and (cfh/touched-group? parent :shapes-group) omit-touched?)
|
(if (and (cfh/touched-group? parent :shapes-group) omit-touched?)
|
||||||
changes
|
changes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue